This is the mail archive of the cygwin mailing list for the Cygwin project.

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: abort during exit() with a dynamically loaded C++ library

On 17/06/2014 19:11, Jon TURNEY wrote:
I think I have found a problem when building programs using the latest
mesa library, where abort is being called during exit()

This seems to be x86 specific, and looks like it is somehow related to
having a C++ library dynamically loaded by a C program.

I think I have reduced it to the following test case:

So, this seems to be related to this patch [1], to fix a different abort during __gcc_deregister_frame()


Since this code is baked into libgcc itself, that patch has the side-effect of making libgcc pin itself in memory.

I can't really tell from what's written there if that was deliberate or not, but it seems that it introduces a different problem when the executable doesn't have a dependency on libgcc.


#include <assert.h>
#include <dlfcn.h>

int main()
    void *h = dlopen("dllib.dll", 0);

The problem can be worked around by adding code to force libgcc to get unloaded here, which seems to support this theory, e.g.

+#define LIBGCC_SONAME "cyggcc_s-1.dll"
+   HANDLE hmod_libgcc = GetModuleHandle(LIBGCC_SONAME);
+   FreeLibrary(hmod_libgcc);


Attached is a patch which modifies __gcc_register_frame() to avoid it pinning itself in memory.

Alternatively, as one of the emails in the linked thread says [2], the assert in __deregister_frame_info_bases() itself could be removed.


Attachment: cygming-crtbegin.c.patch
Description: Text document

Problem reports:
Unsubscribe info:

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]