If foreign code invokes a short callback while also allocating (e.g., because it's invoking the callback in a new thread), then memory could increase indefinitely without a garbage collection triggered. Avoid that situation by making sure that a callback includes a trap check. Also, detect on thread creation whether a collection is pending, and setting the thread's trap value to minimum in that case.
Meanwhile, "foreign4.c" as part of the test suite wasn't checking threading as intended on some platforms (such as macOS), and that's fixed in this commit.
Fixes #102.
If foreign code invokes a short callback while also allocating (e.g., because it's invoking the callback in a new thread), then memory could increase indefinitely without a garbage collection triggered. Avoid that situation by making sure that a callback includes a trap check. Also, detect on thread creation whether a collection is pending, and setting the thread's trap value to minimum in that case.
Meanwhile, "foreign4.c" as part of the test suite wasn't checking threading as intended on some platforms (such as macOS), and that's fixed in this commit.