segfault hunting with material.cpp