From 5b398714738264df0fb4af453cf7912733477f31 Mon Sep 17 00:00:00 2001 From: wuxx1279 Date: Mon, 6 Jul 2026 03:15:36 -0500 Subject: [PATCH] Free Dyninst lock before unloading the RT library in test_thread_1 func1_1() called dlclose(RTlib) before invoking DYNINSTfree_thelock, which is a function pointer resolved via dlsym into that same library. If the dlopen'd handle was the last reference (i.e., it did not resolve to the copy Dyninst injected), dlclose unmaps the library and the subsequent call jumps into unmapped memory, crashing the mutatee with SIGSEGV. This matches the sporadic signal-11 failures seen for test_thread_1. Free the lock while the library is still mapped, then dlclose. Co-Authored-By: Claude Fable 5 --- src/dyninst/test_thread_1_mutatee.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/dyninst/test_thread_1_mutatee.c b/src/dyninst/test_thread_1_mutatee.c index b27dd4f26..97260d189 100644 --- a/src/dyninst/test_thread_1_mutatee.c +++ b/src/dyninst/test_thread_1_mutatee.c @@ -142,9 +142,11 @@ int func1_1() { pthread_join(test1threads[i], NULL); } + /* The lock must be freed before dlclose: DYNINSTfree_thelock points into + * the RT library and is invalid once the library is unmapped. */ + DYNINSTfree_thelock(&test1lock); dlclose(RTlib); pthread_barrier_destroy(&startup_barrier); - DYNINSTfree_thelock(&test1lock); return subtest1err; }