Strange exception handling behaviour with dlopen()

Florian Weimer fw@deneb.enyo.de
Sun Nov 22 17:32:10 GMT 2020


* Laszlo Nemeth:

>>The code throws from an *ELF* constructor (although it uses a C++
>>constructor to achieve this).  This is currently not supported by the
>>glibc implementation.
>
> Can you please Florian elaborate what this "not supported" means?

dlopen is marked as not throwing.  This is easy enough to change.  But
the dynamic linker does not deallocate resources (including locks) if
an ELF constructor throws an exception.  And that is difficult to
correct.

>>It's possible to correct this.  A really clean solution would require
>>that we move the unwinder into glibc.  Maybe it is possible to get the
>>desired effect by using the unwinder that was just loaded to catch the
>>exception, but that seems rather tricky.
>
> Florian, can you please tell what that means?
>
> Is there any reliable way to resolve this with the current gcc and glibc ?

No, it requires glibc changes, and possibly libgcc_s changes.


More information about the Gcc-help mailing list