From 2fd4fddf26173c480c84d5c72b721597c42f09a6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Louis=20Ye=20=E5=8F=B6=E7=BB=BF=E5=AE=87?= Date: Fri, 22 Jun 2018 10:43:47 -0700 Subject: [PATCH] i#3049: clean postcall_cache when drwrap_exit (#3064) This commit is the supplement for PR #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. Issue: #3065, #2157 Fixes #3049 --- ext/drwrap/drwrap.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/ext/drwrap/drwrap.c b/ext/drwrap/drwrap.c index 49b6a0fa499..3d89ce9af61 100644 --- a/ext/drwrap/drwrap.c +++ b/ext/drwrap/drwrap.c @@ -981,6 +981,11 @@ drwrap_exit(void) !dr_unregister_delete_event(drwrap_fragment_delete)) ASSERT(false, "failed to unregister in drwrap_exit"); + for (int i = 0; i < POSTCALL_CACHE_SIZE; i++) { + postcall_cache[i] = NULL; + } + postcall_cache_idx = 0; + hashtable_delete(&replace_table); hashtable_delete(&replace_native_table); hashtable_delete(&wrap_table);