memory corruption

It's not a pull request, I didn't really look at your code,  I've just saw your request today.

General advice: 
Use Gc.compact, not just Gc.full_major. And put it in a often called
function of your library code, not only at application level. I always
overlay any suspicious function with a wrapper of this scheme:

 let f .. =
   Gc.compact ();
   let x = f .. in
   Gc.compact ();
   x

And then run your application with valgrind.
Valgrind did find this error instantly.