In my case the problem was a C++/CLI library in which there was a call to the NtQuerySystemInformation; for some kind of reason sometimes (and under mysterious circumstances), when it was called the CLR heap got corrupted and the application crashed.
I've resolved the problem using a "custom heap" created with HeapCreate and allocating there the buffers used by that function.