Index: src/estream.c =================================================================== --- src/estream.c +++ src/estream.c @@ -471,6 +471,7 @@ +__attribute__((destructor,used)) static void do_deinit (void) { @@ -503,7 +504,16 @@ if (!initialized) { initialized = 1; +#if 0 + /* This library may be unloaded via dlclose() before + * exit() is called, causing the atexit handler to try + * to jump into unmapped address space, causing a segfault. + * This has been observed with apache and php. Instead, use + * the destructor attribute, since that will cause it + * to be called on dlclose() as well. + */ atexit (do_deinit); +#endif } return 0; }