Skip to content

Commit fd3a60a

Browse files
committed
wheel cannot load libunwind.so, wheel names them with a hash included in the name (#157), direcly load from the main programs shared object handle
1 parent df6dce8 commit fd3a60a

File tree

2 files changed

+11
-2
lines changed

2 files changed

+11
-2
lines changed

setup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@ def run(self):
100100
name='vmprof',
101101
author='vmprof team',
102102
author_email='fijal@baroquesoftware.com',
103-
version="0.4.10",
103+
version="0.4.11.dev0",
104104
packages=find_packages(),
105105
description="Python's vmprof client",
106106
long_description='See https://vmprof.readthedocs.org/',

src/vmp_stack.c

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -510,7 +510,6 @@ int vmp_read_vmaps(const char * fname) {
510510
static const char * vmprof_error = NULL;
511511
static void * libhandle = NULL;
512512

513-
514513
#ifdef VMPROF_LINUX
515514
#define LIBUNWIND "libunwind.so"
516515
#ifdef __i386__
@@ -525,9 +524,19 @@ static void * libhandle = NULL;
525524
int vmp_native_enable(void) {
526525
#ifdef VMPROF_LINUX
527526
if (libhandle == NULL) {
527+
// on linux, the wheel includes the libunwind shared object.
528+
libhandle = dlopen(NULL, RTLD_LAZY | RTLD_LOCAL);
529+
if (libhandle != NULL) {
530+
if (dlsym(libhandle, U_PREFIX PREFIX "_getcontext") != NULL) {
531+
goto loaded_libunwind;
532+
}
533+
libhandle = NULL;
534+
}
535+
528536
if ((libhandle = dlopen(LIBUNWIND, RTLD_LAZY | RTLD_LOCAL)) == NULL) {
529537
goto bail_out;
530538
}
539+
loaded_libunwind:
531540
if ((unw_get_reg = dlsym(libhandle, UL_PREFIX PREFIX "_get_reg")) == NULL) {
532541
goto bail_out;
533542
}

0 commit comments

Comments
 (0)