mirror of
https://github.com/OpenNebula/one.git
synced 2026-12-02 05:06:14 +09:00
The previous fix (b001d61b) suppressed FFI::DynamicLibrary finalizers
via ObjectSpace.undefine_finalizer to prevent dlclose() from unmapping
libzmq while ZMQ I/O threads are still running. However, on Ruby 3.4+
(SLES 16), FFI::DynamicLibrary objects are frozen for Ractor-safety,
causing undefine_finalizer to raise FrozenError — silently failing.
Fix both shutdown crash paths:
1) SIGSEGV (dlclose unmaps libzmq): pin libzmq in memory via
Fiddle.dlopen with disable_close, adding a dlopen refcount that
is never decremented. FFI's dlclose then drops the refcount to 1
(not 0), keeping the library mapped.
2) Deadlock (zmq_ctx_term blocks on open sockets): suppress the
ZMQ::Context finalizer via undefine_finalizer (Context objects
are not frozen, so this works on all Ruby versions).
Falls back to the old undefine_finalizer approach on systems without
Fiddle or with a different libzmq soname (works on Ruby < 3.4).