cisco / ChezScheme

Chez Scheme
Apache License 2.0
6.89k stars 983 forks source link

ensure short callbacks get around to a garbage collection #763

Closed mflatt closed 7 months ago

mflatt commented 7 months ago

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.