You can use these two scripts to help identify the error.
They are the exact same except that one has 3 material layers and one has 2. They cause two different errors (one with corruption as described, one processes the information but incorrectly and shows weird symbols in the interpretter). Probably a result of the same bug. Hopefully the files help.