michaelrsweet / mxml

Tiny XML library.
https://www.msweet.org/mxml
Apache License 2.0
426 stars 157 forks source link

shared library cleanup problem #293

Closed scott-snyder closed 1 year ago

scott-snyder commented 1 year ago

hi -

I ran into an issue in fedora 36 where the rosegarden sequencer would crash on startup with a report of EINVAL from pthread_setspecific. See https://bugzilla.redhat.com/show_bug.cgi?id=2089032. The root cause appears to be mxml. In brief: rosegarden scans a set of plugins at startup, loading and unloading shared libraries in turn. One of these links againt mxml. But if mxml is unloaded without any of its functions having been called, then the fini routine will try to call pthread_key_delete without the key having been created. This will thus try to delete key 0, which is likely to be used by some other library, leading to a subsequent crash.

See the above-referenced bugzilla report for a patch that works for me.

michaelrsweet commented 1 year ago

That proposed fix leaks memory if the library has been initialized... But I can combine the two...

erincandescent commented 1 year ago

I'd generally suggest either

(On pretty much every Unix, atexit() functions will be invoked at dlclose() time, for Itanium C++ ABI related reasons)

michaelrsweet commented 1 year ago

OK, merging this issue with #294.

michaelrsweet commented 1 year ago

I've pushed the following change:

[master d32818a] Another POSIX thread destructor fix (Issue #293)

Please let me know whether this fixes the reported issue, then I'll put out a bug fix release (3.3.1).

ConiKost commented 1 year ago

Hi! It looks like, that your patches fixed the issue, which also someone reported at Gentoo: https://bugs.gentoo.org/860804