The nondeterministic crashes are due to a small stack. You need a larger stack here. In my testing 32K was sufficient.