Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ensure short callbacks get around to a garbage collection #763

Merged
merged 1 commit into from
Nov 28, 2023

Conversation

mflatt
Copy link
Contributor

@mflatt mflatt commented Nov 22, 2023

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.

If foreign code invaokes 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.
@mflatt mflatt merged commit 1c0888c into cisco:main Nov 28, 2023
13 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Memory leak when foreign-callable function called by multiple foreign thread.
2 participants