-
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#3049: clean postcall_cache when drwrap_exit #3064
i#3049: clean postcall_cache when drwrap_exit #3064
Conversation
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
ext/drwrap/drwrap.c
Outdated
@@ -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); |
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.
Please declare i on a separate line: I find this harder to read
ext/drwrap/drwrap.c
Outdated
@@ -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; | |||
} |
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 is fine for this CL but it brings up two thoughts:
-
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.
-
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.
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.
Sure
Move `i` declaration inside for loop Fixes DynamoRIO#3049, DynamoRIO#3065
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.
LGTM
This commit is a supplement for PR #3050.
We need to clean
postcall_cache
ondrwrap_exit
as well, otherwisepost-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 inpostcall_cache
prevents post-callback being registered to the hash table.Fixes #3049