Fyi, your struct is half an mb in size! That is incredibly huge, and I wouldn't necessarily go via sys_malloc() here (I don't know the implementation of it, and I don't know how well it handles allocations of that size. Memory managers are incredibly hard to write in a good way, and the OS system allocators have improved quite a lot in the recent years, in a way that I wouldn't count on a home brewed alternative unless I knew it was using something like tcmalloc internally).

In all seriousness though, you really ought to improve your struct and allocations. Your static allocations are way out of hand. Even if that's not the source of your error, it's going to be a problem at some point! (as Uhrwerk pointed out, it seems like you ended up either making inst a dangling pointer or forget to initialize it somewhere while dropping the other instance or...).


Shitlord by trade and passion. Graphics programmer at Laminar Research.
I write blog posts at feresignum.com