-
Notifications
You must be signed in to change notification settings - Fork 566
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
i#2571 exit flags not reset: reset on init. #2572
Conversation
Tested: ctest,internal repro. Fixes DynamoRIO#2571
core/heap.c
Outdated
@@ -1401,6 +1401,9 @@ vmm_heap_init() | |||
if (DYNAMO_OPTION(vm_reserve)) { | |||
vmm_heap_unit_init(&heapmgt->vmheap, DYNAMO_OPTION(vm_size)); | |||
} | |||
dynamo_vm_areas_lock(); | |||
heap_exiting = false; |
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.
Hmm, the approach for #2157 has been the opposite, to pay a cost only when exiting on a detach. It may seem uglier, but init time does matter: we want to support running shell scripts and other sequences with a series of rapid process creation and teardown events. Furthermore, explicit initialization of globals causes extra overhead beyond just a memory store by incurring copy-on-write costs (.bss is part of the shared image on Windows).
We also have an invariant where our process init routines can avoid the cost of locks: only one thread will be in DR during process init.
If this were "regular" code I would agree that this is cleaner, but I think for DR we should avoid unnecessary work. I'm sure this single lock and store won't be measurable by itself but if we did this for every static var it will likely have a noticeable impact.
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.
Are you suggesting just not grabbing the lock because there's only one thread during init? I think that's safe on x86 (acquire-release semantics by default), but wasn't sure about ARM.
Or you mean flipping the flags back once detach is over?
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.
Reading a bit closer, you meant the latter. Implemented similarly to #2157.
Also, it's moot grabbing dynamo_vm_areas_lock() at that point, because it's already NULL and this is the only DR thread left.
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.
Right. (Re: init on ARM (now unrelated to the code): should be fine with just one barrier at the very end.)
This reverts commit 34dfb78.
The travis failure is unrelated and known (#2003). |
Tested: ctest,internal repro.
Fixes #2571