delorie.com/archives/browse.cgi   search  
Mail Archives: cygwin/2010/06/17/08:03:49

X-Recipient: archive-cygwin AT delorie DOT com
X-SWARE-Spam-Status: No, hits=-1.7 required=5.0 tests=AWL,BAYES_00,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FROM,TW_CX,T_TO_NO_BRKTS_FREEMAIL
X-Spam-Check-By: sourceware.org
Message-ID: <4C1A11EF.9000405@gmail.com>
Date: Thu, 17 Jun 2010 13:15:43 +0100
From: Dave Korn <dave DOT korn DOT cygwin AT gmail DOT com>
User-Agent: Thunderbird 2.0.0.17 (Windows/20080914)
MIME-Version: 1.0
To: cygwin AT cygwin DOT com
Subject: Re: C++ app segfaults in libstdc++
References: <4C198B44 DOT 6040803 AT cwilson DOT fastmail DOT fm>
In-Reply-To: <4C198B44.6040803@cwilson.fastmail.fm>
X-IsSubscribed: yes
Mailing-List: contact cygwin-help AT cygwin DOT com; run by ezmlm
List-Id: <cygwin.cygwin.com>
List-Subscribe: <mailto:cygwin-subscribe AT cygwin DOT com>
List-Archive: <http://sourceware.org/ml/cygwin/>
List-Post: <mailto:cygwin AT cygwin DOT com>
List-Help: <mailto:cygwin-help AT cygwin DOT com>, <http://sourceware.org/ml/#faqs>
Sender: cygwin-owner AT cygwin DOT com
Mail-Followup-To: cygwin AT cygwin DOT com
Delivered-To: mailing list cygwin AT cygwin DOT com

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

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019