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#3049: clean postcall_cache when drwrap_exit #3064

Merged
merged 4 commits into from
Jun 22, 2018

Conversation

Louis-Ye
Copy link
Contributor

@Louis-Ye Louis-Ye commented Jun 21, 2018

This commit is a supplement for PR #3050.
We need to clean postcall_cache on drwrap_exit as well, otherwise
post-callback (one of the arguments when calling drwrap_wrap_ex) will not be invoked at re-attach. This is because the registration of post-callback relies on pre-callback, and pre-callback checks postcall-cache before registering the post-callback. Stale data in postcall_cache prevents post-callback being registered to the hash table.

Fixes #3049

Louis-Ye and others added 2 commits June 20, 2018 19:39
This commit is the supplement for PR DynamoRIO#3050.
We also need to clean postcall_cache on drwrap_exit, otherwise
post_callback will not be invoked at re-attach. This is because the registration
of post_callback relies on pre_callback, and the pre_callback checks postcall_cache
before registering the post_callback. The stale data in postcall_cache prevents
post_callback being registered to the hash table.

Fixes DynamoRIO#3049
Add var declaration to fix build.

Fixes DynamoRIO#3049
@@ -970,7 +970,7 @@ void
drwrap_exit(void)
{
/* handle multiple sets of init/exit calls */
int count = dr_atomic_add32_return_sum(&drwrap_init_count, -1);
int i, count = dr_atomic_add32_return_sum(&drwrap_init_count, -1);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please declare i on a separate line: I find this harder to read

@@ -981,6 +981,11 @@ drwrap_exit(void)
!dr_unregister_delete_event(drwrap_fragment_delete))
ASSERT(false, "failed to unregister in drwrap_exit");

for (i = 0; i < POSTCALL_CACHE_SIZE; i++) {
postcall_cache[i] = NULL;
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is fine for this CL but it brings up two thoughts:

  1. For large data structures zeroing at exit is costly when there's no chance or re-attach: which is all of the time for regular non-static DR. Inside DR we only zero for doing_detach. We may want to export that for extensions.

  2. We should add a re-attach test for drwrap.

I filed #3065 for this, split from #2157. Let's reference both issues in the merge commit message.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sure

Copy link
Contributor

@derekbruening derekbruening left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@derekbruening derekbruening merged commit 2fd4fdd into DynamoRIO:master Jun 22, 2018
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