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

i#2571 exit flags not reset: reset on init. #2572

Merged
merged 3 commits into from
Jul 29, 2017

Conversation

s-kanev
Copy link
Contributor

@s-kanev s-kanev commented Jul 28, 2017

Tested: ctest,internal repro.

Fixes #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;
Copy link
Contributor

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.

Copy link
Contributor Author

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?

Copy link
Contributor Author

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.

Copy link
Contributor

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.)

@s-kanev
Copy link
Contributor Author

s-kanev commented Jul 29, 2017

The travis failure is unrelated and known (#2003).

@derekbruening derekbruening merged commit 70a731b into DynamoRIO:master Jul 29, 2017
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.

2 participants