dlclose() causing segmentation fault on exit from main()
From: Exillis (news_at_exillis.com)
Date: 08/31/04
- Next message: Ryan J Alder: "Serial port project - possible?"
- Previous message: Mark Burgo: "Re: Versasoft dBMAN for Linux"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Date: 31 Aug 2004 07:13:25 -0700
Hi,
I'm running into a problem on Linux while dynamically loading and
unloading DSOs. The problem is, if I build with --fuse-cxa-atexit I
get a segmentation fault on exit from main() after I've done a
dlclose() on a DSO and then exit from main(). Commenting out dlclose()
or compiling with --fno-use-cxa-atexit avoids the segmentation fault.
My compiler is gcc 3.3 (distro is SuSE 9.0).
The seg fault occurs after main() so I cannot set a breakpoint. It
seems what's happening is that the DSO has registered destructor calls
with atexit() and when main() invokes the destructors (via atexit or
_cxa_atexit()) it crashes because the DSO has previously been
unloaded.
>From what I can gather, if I avoid all function-scoped static objects
(and static objects declared in anonymous namespaces) the crash won't
occur. I tried that. I removed all global static objects and
function-scoped static objects and the seg fault still occurs. At this
point I don't know where to look to debug this further.
I don't want to rely on building with --fno-use-cxa-atexit. I'd like
to fix my code and not just cover up the problem with a compiler
switch.
Has anyone come up with a way to solve this? How can I track done
which destructor is still being registered for invoking at exit from
main()? I'm hoping to find a global or static object that I missed
somewhere (this is a large code base and I may have missed something).
Thanks for any help with this!
Michael
- Next message: Ryan J Alder: "Serial port project - possible?"
- Previous message: Mark Burgo: "Re: Versasoft dBMAN for Linux"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]