public inbox for cygwin@cygwin.com
 help / color / mirror / Atom feed
* gcc-6.3.0-1 regression: libstdc++6 DLL breaks exception handling
@ 2017-01-26 10:31 Christian Franke
  2017-02-07 10:04 ` JonY
  0 siblings, 1 reply; 3+ messages in thread
From: Christian Franke @ 2017-01-26 10:31 UTC (permalink / raw)
  To: cygwin

After upgrading to gcc test version 6.3.0-1, C++ exception handling is 
broken if DLL version of new libstdc++6 is used.

Testcase:

$ uname -srvmo
CYGWIN_NT-10.0-WOW 2.6.1(0.305/5/3) 2016-12-16 11:50 i686 Cygwin
or:
CYGWIN_NT-10.0 2.6.1(0.305/5/3) 2016-12-16 11:55 x86_64 Cygwin

$ cygcheck -f /bin/g++
gcc-g++-6.3.0-1

$ cygcheck -f /bin/cygstdc++-6.dll
libstdc++6-6.3.0-1

$ cat exc.cc
int main()
{
   try {
     throw 42;
   }
   catch (int i) {
     return i;
   }
   return 0;
}

$ g++ -o exc exc.cc

$ ./exc
Segmentation fault (core dumped)


Workaround: Use statically linked version of new libstdc++6:

$ g++ -static -o exc-static exc.cc

$ ./exc-static

$ echo $?
42


Or: Downgrade cygstdc++6.dll:

$ cygcheck -f /bin/cygstdc++-6.dll
libstdc++6-5.4.0-1

$ ./exc

$ echo $?
42


This also affects existing packages compiled with older g++, for example:

$ /usr/sbin/smartctl -V
smartctl 6.5 2016-05-07 r4318 [x86_64-unknown-cygwin-win10] (cygwin-6.5-1)
...
smartmontools build with: C++98, GCC 5.3.0
...
Segmentation fault (core dumped)


Regards,
Christian


--
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

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: gcc-6.3.0-1 regression: libstdc++6 DLL breaks exception handling
  2017-01-26 10:31 gcc-6.3.0-1 regression: libstdc++6 DLL breaks exception handling Christian Franke
@ 2017-02-07 10:04 ` JonY
  2017-02-07 15:27   ` Christian Franke
  0 siblings, 1 reply; 3+ messages in thread
From: JonY @ 2017-02-07 10:04 UTC (permalink / raw)
  To: cygwin


[-- Attachment #1.1: Type: text/plain, Size: 240 bytes --]

On 01/26/2017 10:30 AM, Christian Franke wrote:
> After upgrading to gcc test version 6.3.0-1, C++ exception handling is
> broken if DLL version of new libstdc++6 is used.
> 

Noted, I'll consider the test version broken for now.



[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 829 bytes --]

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: gcc-6.3.0-1 regression: libstdc++6 DLL breaks exception handling
  2017-02-07 10:04 ` JonY
@ 2017-02-07 15:27   ` Christian Franke
  0 siblings, 0 replies; 3+ messages in thread
From: Christian Franke @ 2017-02-07 15:27 UTC (permalink / raw)
  To: cygwin

JonY wrote:
> On 01/26/2017 10:30 AM, Christian Franke wrote:
>> After upgrading to gcc test version 6.3.0-1, C++ exception handling is
>> broken if DLL version of new libstdc++6 is used.
>>
> Noted, I'll consider the test version broken for now.
>
>

Meantime I examined the testcase with gdb: The DLL exports a bogus 
address for the symbol "_ZTIi" ('typeinfo for int'). This results in 
this more simple testcase:

#include <typeinfo>
int main() {
   const std::type_info & ti = typeid(int); // &_ZTIi from DLL
   const char * p = ti.name(); // segfaults because &_ZTIi is bogus.
}


And indeed, the export table of the DLL looks 'interesting'. The offsets 
of various exported symbols are apparently all 93980000:

$ objdump -p cygstdc++-6.dll

     [5142] +base[5143] c6760 Export RVA
     [5143] +base[5144] c6768 Export RVA
     [5144] +base[5145] 93980000 Export RVA
...
     [5151] +base[5152] 93980000 Export RVA
     [5152] +base[5153] 93980000 Export RVA
     [5153] +base[5154] 93980000 Export RVA
     [5154] +base[5155] 93980000 Export RVA
...
     [5167] +base[5168] 93980000 Export RVA
     [5168] +base[5169] c6780 Export RVA
...
[Ordinal/Name Pointer] Table
...
     [5143] _ZTISt9type_info
     [5144] _ZTIa
...
     [5151] _ZTIh
     [5152] _ZTIi
     [5153] _ZTIj
     [5154] _ZTIl
...
     [5167] _ZTSDs
     [5168] _ZTSN10__cxxabiv115__forced_unwindE

$  objdump -p cygstdc++-6.dll | grep -cw 93980000
759


Hmm... bug in the (bin)utils used to build the DLL?

Possibly related:
https://cygwin.com/ml/cygwin/2017-01/msg00375.html

Christian


--
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

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2017-02-07 15:27 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-01-26 10:31 gcc-6.3.0-1 regression: libstdc++6 DLL breaks exception handling Christian Franke
2017-02-07 10:04 ` JonY
2017-02-07 15:27   ` Christian Franke

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).