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: C++ app segfaults in libstdc++


On 17/06/2010 03:41, Charles Wilson wrote:

> Any ideas?

  Yes, I have one:

>   catch (modexc e) {
>     std::cerr << "caught: " << e.what () << '\n';
>     if (dlclose (handle))
>       {
>         std::cerr << "dlclose failed: " << dlerror () << '\n';
>         return 1;
>       }
>     return 0;
>   }

  You're unloading the module, before the exception that it threw goes out of
scope.

  At this time, the modexc object e has not yet been destructed, the catch is
still 'live', and when you attempt to exit the catch block, __cxa_end_catch
gets fatally confused.  The live exception still contains pointers into where
the dll used to be loaded: it has typeinfo there, and a pointer to the
module's inlined instance of the ~modexc() dtor.

  I think the rule is: Don't unload a shared library while you still have a
live C++ object from it, unless that object is a POD.

    cheers,
      DaveK

--
Problem reports:       http://cygwin.com/problems.html
FAQ:                   http://cygwin.com/faq/
Documentation:         http://cygwin.com/docs.html
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple


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