Segmentation fault in _fini()

I have a static class library that I link with. Whenever I link with this
library there is a
segmentation fault in a function called after returning from main() called
_fini().
If I catch the signal and call the function _exit() the process exits
normally. Can anyone
explain this behavior?

thanks

Kevin

“Kevin Brown” <kbrown@bytewise.com> wrote in
news:a4bi7j$h08$1@inn.qnx.com:

I have a static class library that I link with. Whenever I link with
this library there is a
segmentation fault in a function called after returning from main()
called _fini().
If I catch the signal and call the function _exit() the process exits
normally. Can anyone
explain this behavior?

_fini is a function a shared library has, which will get called just before
it’s being unmapped. Typically, you’d see code that does a dlopen() on a
shared lib, and then a dlclose() would elicit the _fini call (only when the
reference count reached zero. ie. if you dlopen() the same lib 3 times,
you’d have to dlclose() it 3 times before _fini would be called).


\

Cheers,
Adam

QNX Software Systems Ltd.
[ amallory@qnx.com ]

With a PC, I always felt limited by the software available.
On Unix, I am limited only by my knowledge.
–Peter J. Schoenster <pschon@baste.magibox.net>

Well, if you’re calling _exit() you’re hardly exitting “normally” :wink:

_exit() bypasses a lot of the cleanup that exit() does, which explains why
the crash doesn’t happen if you exit in this manner. That’s a heavy-handed
(or, in this case I suppose an overly light-handed) way to solve the
problem, so instead let’s try and figure out what’s causing the crash.

What are you doing in the destructors for your static classes?


“Adam Mallory” <amallory@qnx.com> wrote in message
news:Xns91B3A5674CF99amalloryqnxcom@209.226.137.4

“Kevin Brown” <> kbrown@bytewise.com> > wrote in
news:a4bi7j$h08$> 1@inn.qnx.com> :

I have a static class library that I link with. Whenever I link with
this library there is a
segmentation fault in a function called after returning from main()
called _fini().
If I catch the signal and call the function _exit() the process exits
normally. Can anyone
explain this behavior?

_fini is a function a shared library has, which will get called just
before
it’s being unmapped. Typically, you’d see code that does a dlopen() on a
shared lib, and then a dlclose() would elicit the _fini call (only when
the
reference count reached zero. ie. if you dlopen() the same lib 3 times,
you’d have to dlclose() it 3 times before _fini would be called).


\

Cheers,
Adam

QNX Software Systems Ltd.
[ > amallory@qnx.com > ]

With a PC, I always felt limited by the software available.
On Unix, I am limited only by my knowledge.
–Peter J. Schoenster <> pschon@baste.magibox.net

I first though of destructors of static objects, but if the fault is there
would not the
debugger show the it in the backtrace instead of _fini()? Anyway I’m going
to
look through the objects destructors for the static objects and see if I can
spot a problem.

Thanks

Kevin