-
Notifications
You must be signed in to change notification settings - Fork 24
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
Fix data races for _lf_count_payload_allocations and _lf_count_token_allocations #313
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This looks reasonable, though it's unfortunate to grab a lock just to facilitate a warning that shouldn't be necessary if the code is working properly. Also, I can't find anywhere in the code that _lf_count_token_allocations
is incremented. Is it only decremented? These revisions seem to only protect alterations of _lf_count_payload_allocations
.
You are probably right about the token_allocations, I didn't check that properly, this was addressing the payload allocations yes. I guess it could be hidden behind a NDEBUG flag so it is only compiled if the user specifies a debug build |
@edwardalee I did the following:
|
Hmmm, I believe that there still are issues. I am experiencing non-deterministic failures in a program that I have made that uses tokens with custom allocators. It runs out of buffers to allocate. My guess is that there are some other data races in the token logic. The token API is invoked from different contexts, sometimes the environment mutex is held, sometimes it is not. |
Update: I found the culprit. When marking a token input as mutable, I think we should take a good look at the token system and identify where there are possible race conditions. There might be more |
@edwardalee and @erlingrj, what should happen with this PR? |
This PR does two things:
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This looks good to me. I've pushed some changes that make use of macros to check return values more uniform and complete and to remove duplication of checking code.
One this that is not clear to me is how a user should set the NDEBUG flag. How to do this @erlingrj ?
It is a convention/standard that NDEBUG (not debug) will be defined by the compilators in release builds. This is how normal |
I noticed large values for number of unfreed messages being reported at termination. I found out that the these global variables are accessed without locking from e.g. reaction bodies. Another valid question is if there are more global state which should be protected in the token handling code.