]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
tools: do not unload plugins during destruction.
authorWillem Jan Withagen <wjw@digiware.nl>
Sun, 11 Apr 2021 13:01:22 +0000 (15:01 +0200)
committerKefu Chai <tchaikov@gmail.com>
Thu, 1 Sep 2022 17:08:25 +0000 (01:08 +0800)
FreeBSD ceph-dencoder crashes in the exit() calls, due to
invalid pointer references during the release process of
the loaded libraries.

Often this is signaled by libc reporting:
  __cxa_thread_call_dtors: dtr 0x47efc0 from unloaded dso, skipping

The cause for this is different behaviour between FreeBSD and Linux:
https://groups.google.com/g/bsdmailinglist/c/22ncTZAbDp4/m/Dii_pII5AwAJ
_The FreeBSD implementation here looks racy. If one thread dlcloses an
object while another thread is exiting, we can end up calling a
function at an invalid memory address. It also looks as if it may
be possible to unload one library, load another at the same address,
and end up executing entirely the wrong code, which would have some
serious security implications.

The GNU/Linux equivalent of this function locks the DSO in memory
until all references to it have gone away. A call to dlclose() on
GNU/Linux will not actually unload the library until all threads
with destructors in that library have been unloaded. I believe
that this reuses the same reference counting mechanism that
allows the same library to be dlopened and dlclosed multiple times.

Signed-off-by: Willem Jan Withagen <wjw@digiware.nl>
(cherry picked from commit 78d301098f6ead7fc341b68d7ac5e0a1cd3295c5)

src/tools/ceph-dencoder/ceph_dencoder.cc

index 2bb73db0854e272f4b250b2c1ad64eb857b0ff6a..20e84c5db24d26fbfd55e6ddc5af3888894cce22 100644 (file)
@@ -74,9 +74,11 @@ public:
     }
   }
   ~DencoderPlugin() {
+#if !defined(__FreeBSD__)
     if (mod) {
       dlclose(mod);
     }
+#endif
   }
   int register_dencoders() {
     assert(mod);