mercury-hpc / mercury

Mercury is a C library for implementing RPC, optimized for HPC.
http://www.mcs.anl.gov/projects/mercury/
BSD 3-Clause "New" or "Revised" License
168 stars 62 forks source link

libmercury_util.so.4 causes a segfault on exit when leveraged through Python/CFFI #729

Closed bgeltz closed 6 months ago

bgeltz commented 6 months ago

Describe the bug When using Python and CFFI to dlopen any library that has a dependency on libmercury.so.2, a segfault occurs when Python exits, pointing to libmercury_util.so.4.

To Reproduce

  1. Ensure cffi is available: zypper install python3-cffi
  2. Install Mercury: zypper install mercury mercury-devel
  3. Create repro.py with the following contents:
    
    import cffi

gffi = cffi.FFI() dl_mercury = gffi.dlopen('libmercury.so.2')

4. Run repro.py with the system Python interpreter and observe the segfault:

$ python3 repro.py Segmentation fault (core dumped)


**Expected behavior**
No segfault occurs when Python is unloaded.

**Platform:**
 - OS = SLES 15.4
 - mercury and mercury-devel version reported by zypper = 2.3.1-2.suse.lp155
 - System Python = 3.6.15
 - System Python CFFI version = 1.13.2

**Additional context**
The stack trace of ```python3``` at the time of the segfault as reported by coredumpctl is:

0 0x000014ffd1989a50 n/a (libmercury_util.so.4 + 0x3a50)

1 0x000014ffd242e843 _dl_fini (ld-linux-x86-64.so.2 + 0x11843)

2 0x000014ffd1f54a99 __run_exit_handlers (libc.so.6 + 0x4da99)

3 0x000014ffd1f54c2a exit (libc.so.6 + 0x4dc2a)

4 0x000014ffd1f3c254 __libc_start_main (libc.so.6 + 0x35254)

5 0x000055d2ebe61d5a _start (python3.6 + 0xd5a)

soumagne commented 6 months ago

thanks for reporting the issue, I was able to reproduce it, this seems specific to having mercury compiled with support for dynamic plugins (which is the default for mercury rpms). Looking into a fix now.

soumagne commented 6 months ago

fix was merged, I'll propagate the fix into the mercury-2.3.1-3 rpm as well.

bgeltz commented 6 months ago

Thanks! Much appreciated.

bgeltz commented 5 months ago

Was this fix ever propagated into mercury-2.3.1-3? If yes, where are those RPMs available?

soumagne commented 5 months ago

it was internally but I'm not sure you'll be able to see it until a new release of DAOS is made because of the SDL process. Which repo are you using for your rpms ?

bgeltz commented 5 months ago

That's a great question. Let me chase this internally and see what I can figure out. Thanks!