nearinfinity/node-java — pull request #72 by inolen (2013-09-28 23:02:59+00:00)
Title: store jthrowable instances as global references

https://github.com/nearinfinity/node-java/pull/45 appears to have attempted to resolve one issue with exceptions. However, in doing so it stored a local reference to the exception, which is then subject to GC after the current stack frame exits.

For me, this was causing seg faults when doing a large amount of parallel processing with node-java.

After reading through http://mail-archives.apache.org/mod_mbox/harmony-dev/200703.mbox/%3Cb6cb498e0703230901i28180bdft1e698283fc318493@mail.gmail.com%3E it appears the correct fix appears to be to store a local reference to the exception handle, clear the exception, and then to create a global reference to the exception handle.

This resolves both the issue in #45 as well as the current seg faults due to the local reference storage.