[pypy-commit] pypy vmprof-native: dlclose must be called later, it worked for cpython because the process already holds a reference to libunwind and dlclose does not gargabe collect

plan_rich pypy.commits at gmail.com
Wed Mar 22 14:30:11 EDT 2017


Author: Richard Plangger <planrichi at gmail.com>
Branch: vmprof-native
Changeset: r90791:e72336569fc5
Date: 2017-03-22 15:29 -0300
http://bitbucket.org/pypy/pypy/changeset/e72336569fc5/

Log:	dlclose must be called later, it worked for cpython because the
	process already holds a reference to libunwind and dlclose does not
	gargabe collect

diff --git a/rpython/rlib/rvmprof/src/shared/vmp_stack.c b/rpython/rlib/rvmprof/src/shared/vmp_stack.c
--- a/rpython/rlib/rvmprof/src/shared/vmp_stack.c
+++ b/rpython/rlib/rvmprof/src/shared/vmp_stack.c
@@ -451,6 +451,7 @@
 #endif
 
 static const char * vmprof_error = NULL;
+static void * libhandle = NULL;
 
 
 #ifdef VMPROF_LINUX
@@ -469,10 +470,7 @@
 #define UL_PREFIX ""
 #endif
 
-extern void * __vmprof_eval_vmprof_addr;
-
 int vmp_native_enable(void) {
-    void * libhandle;
     vmp_native_traces_enabled = 1;
 
     if (!unw_get_reg) {
@@ -500,9 +498,6 @@
         if (!(unw_getcontext = dlsym(libhandle, U_PREFIX PREFIX "_getcontext"))) {
             goto bail_out;
         }
-        if (dlclose(libhandle)) {
-            goto bail_out;
-        }
     }
 
 #if defined(__unix__)
@@ -518,6 +513,14 @@
 }
 
 void vmp_native_disable(void) {
+
+    if (libhandle != NULL) {
+        if (dlclose(libhandle)) {
+            vmprof_error = dlerror();
+            fprintf(stderr, "could close libunwind at runtime. error: %s\n", vmprof_error);
+        }
+    }
+
     vmp_native_traces_enabled = 0;
     if (vmp_ranges != NULL) {
         free(vmp_ranges);


More information about the pypy-commit mailing list