-
Notifications
You must be signed in to change notification settings - Fork 13
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
Should use THREADCHECK instead of ASSERT_R_THREAD() #7
Comments
Cool! Do these macro's prevent the GC from running in a non-main thread? |
Yes, I believe that if it tries to do GC in a thread, it calls The first link above was previously incorrect, but I've fixed it, and if you follow it you can see how it works. Just curious: in your work, have you had problems with GC in other threads? |
I avoid calling the R api in threads because afaik none of the api's are thread-safe due to the random GC runs. I was hoping these changes could help with suspending the GC in threads, but I guess that is not the purpose here :) |
Fixed in e9899c3. |
@jeroen I think the problem is even worse than having GC events run in the wrong thread. If you do any R memory management at all in a different thread, there's the possibility of memory corruption due to races. For example, if you look at wch/r-source@5cf1f4b, you can see that But I agree about the overall lesson: don't call the R API from a different thread. |
As of
wch/r-source@3c59cea, R itself has a
THREADCHECK
macro to make sure that various functions are called from the correct thread.Commit wch/r-source@5cf1f4b also added the checks that were in
ASSERT_R_THREAD()
.The assertthread build should be changed to use the built-in checks.
The text was updated successfully, but these errors were encountered: