I built a x86_64-pc-mingw32 toolchain from scratch with the newest code from
SVN ( 20090421 ).
and the build an application using wxWidgets library, it runs crashed.

(gdb) r
Starting program: E:\code\DMediaInfo/DMediaInfo.exe
[New Thread 2656.0xbd8]
warning: Can not parse XML library list; XML support was disabled at
compile tim
e
[New Thread 2656.0x964]
Program received signal SIGSEGV, Segmentation fault.
0x00000000006e289b in wxObject (this=0x1)
at f:/devel/devel64/include/wx/object.h:412
412 wxObject() { m_refData = NULL; }
Current language: auto; currently c++
(gdb) p this
$1 = (class wxObject * const) 0x1


the wxObject was create by new operator, it return 0x1 which is wrong.

------------------
44 _GLIBCXX_WEAK_DEFINITION void *
45 operator new (std::size_t sz) throw (std::bad_alloc)
46 {
47 void *p;
48
49 /* malloc (0) is unpredictable; avoid it. */
50 if (sz == 0)
51 sz = 1;
52 p = (void *) malloc (sz);
53 while (p == 0)
54 {
55 new_handler handler = __new_handler;
56 if (! handler)
57 #ifdef __EXCEPTIONS
58 throw bad_alloc();
59 #else
60 std::abort();
61 #endif
62 handler ();
63 p = (void *) malloc (sz);
64 }
65
66 return p;
67 }
--------------------------------

malloc() return the correct value, but after _Unwind_SjLj_Unregister(),
$rax changed to 0x1.

----------------------
Dump of assembler code for function _Znwy:
0x0000000000702d50 <_Znwy+0>: push %rbp
0x0000000000702d51 <_Znwy+1>: lea 0x11e8(%rip),%rax # 0x703f40
<__gx
x_personality_sj0>
0x0000000000702d58 <_Znwy+8>: lea 0x7ea9(%rip),%rdx # 0x70ac08
<__DT
OR_LIST__+24584>
0x0000000000702d5f <_Znwy+15>: sub $0x90,%rsp
0x0000000000702d66 <_Znwy+22>: mov %rcx,0xa0(%rsp)
0x0000000000702d6e <_Znwy+30>: mov %rax,0x50(%rsp)
0x0000000000702d73 <_Znwy+35>: lea 0x20(%rsp),%rcx
0x0000000000702d78 <_Znwy+40>: lea 0x90(%rsp),%rax
0x0000000000702d80 <_Znwy+48>: mov %rdx,0x58(%rsp)
0x0000000000702d85 <_Znwy+53>: lea 0xb1(%rip),%rdx # 0x702e3d
<_Znwy+
237>
0x0000000000702d8c <_Znwy+60>: mov %rsp,0x70(%rsp)
0x0000000000702d91 <_Znwy+65>: mov %rax,0x60(%rsp)
0x0000000000702d96 <_Znwy+70>: mov %rdx,0x68(%rsp)
0x0000000000702d9b <_Znwy+75>: callq 0x68df08 <_Unwind_SjLj_Register>
0x0000000000702da0 <_Znwy+80>: cmpq $0x0,0xa0(%rsp)
0x0000000000702da9 <_Znwy+89>: mov $0x1,%eax
0x0000000000702dae <_Znwy+94>: cmovne 0xa0(%rsp),%rax
0x0000000000702db7 <_Znwy+103>: mov %rax,%rcx
0x0000000000702dba <_Znwy+106>: mov %rax,0xa0(%rsp)
0x0000000000702dc2 <_Znwy+114>: callq 0x68f708 <malloc>
0x0000000000702dc7 <_Znwy+119>: test %rax,%rax
0x0000000000702dca <_Znwy+122>: jne 0x702df8 <_Znwy+168>
0x0000000000702dcc <_Znwy+124>: nopl 0x0(%rax)
0x0000000000702dd0 <_Znwy+128>: mov 0x49861(%rip),%rax # 0x74c638
<__n
ew_handler>
0x0000000000702dd7 <_Znwy+135>: test %rax,%rax
0x0000000000702dda <_Znwy+138>: je 0x702e0b <_Znwy+187>
0x0000000000702ddc <_Znwy+140>: movl $0x1,0x28(%rsp)
0x0000000000702de4 <_Znwy+148>: callq *%rax
0x0000000000702de6 <_Znwy+150>: mov 0xa0(%rsp),%rcx
0x0000000000702dee <_Znwy+158>: callq 0x68f708 <malloc>
0x0000000000702df3 <_Znwy+163>: test %rax,%rax
0x0000000000702df6 <_Znwy+166>: je 0x702dd0 <_Znwy+128>
0x0000000000702df8 <_Znwy+168>: lea 0x20(%rsp),%rcx
0x0000000000702dfd <_Znwy+173>: callq 0x68df10 <_Unwind_SjLj_Unregister>
0x0000000000702e02 <_Znwy+178>: add $0x90,%rsp
0x0000000000702e09 <_Znwy+185>: pop %rbp
0x0000000000702e0a <_Znwy+186>: retq
0x0000000000702e0b <_Znwy+187>: mov $0x8,%ecx
0x0000000000702e10 <_Znwy+192>: callq 0x703090 <__cxa_allocate_exception>
0x0000000000702e15 <_Znwy+197>: lea 0x49754(%rip),%rdx # 0x74c570
<_ZT
VSt9bad_alloc+16>
0x0000000000702e1c <_Znwy+204>: lea -0x1dd3(%rip),%r8 # 0x701050
<~bad
_alloc>
0x0000000000702e23 <_Znwy+211>: mov %rax,%rcx
0x0000000000702e26 <_Znwy+214>: mov %rdx,(%rax)
0x0000000000702e29 <_Znwy+217>: lea 0x186f0(%rip),%rdx # 0x71b520
<_ZT
ISt9bad_alloc>
0x0000000000702e30 <_Znwy+224>: movl $0x1,0x28(%rsp)
0x0000000000702e38 <_Znwy+232>: callq 0x703ee0 <__cxa_throw>
0x0000000000702e3d <_Znwy+237>: mov 0x38(%rsp),%rax
0x0000000000702e42 <_Znwy+242>: mov 0x30(%rsp),%rcx
0x0000000000702e47 <_Znwy+247>: cmp $0xffffffffffffffff,%rax
0x0000000000702e4b <_Znwy+251>: je 0x702e5a <_Znwy+266>
0x0000000000702e4d <_Znwy+253>: movl $0xffffffff,0x28(%rsp)
0x0000000000702e55 <_Znwy+261>: callq 0x68df00 <_Unwind_SjLj_Resume>
0x0000000000702e5a <_Znwy+266>: mov %eax,0x28(%rsp)
0x0000000000702e5e <_Znwy+270>: callq 0x7034c0 <__cxa_call_unexpected>
End of assembler dump.
(gdb)

Breakpoint 2, 0x0000000000702dfd in operator new (sz=64)
at ../../../../gcc/libstdc++-v3/libsupc++/new_op.cc:53
53 ../../../../gcc/libstdc++-v3/libsupc++/new_op.cc: No such file or
direct
ory.
in ../../../../gcc/libstdc++-v3/libsupc++/new_op.cc
(gdb) echo $pc
$pc(gdb) p $pc
$28 = (void (*)(void)) 0x702dfd <operator new(unsigned long long)+173>
(gdb) p $rax
$29 = 63978736
(gdb) p $rcx
$30 = 2292480
(gdb) x/i $pc
0x702dfd <_Znwy+173>: callq 0x68df10 <_Unwind_SjLj_Unregister>
(gdb) ni
67 in ../../../../gcc/libstdc++-v3/libsupc++/new_op.cc
(gdb) p $pc
$31 = (void (*)(void)) 0x702e02 <operator new(unsigned long long)+178>
(gdb) p $rax
$32 = 1
(gdb)
-------------------

E:\code\DMediaInfo>gcc -v
Using built-in specs.
Target: x86_64-pc-mingw32
Configured with: ../gcc/configure --host=x86_64-pc-mingw32
--target=x86_64-pc-mi
ngw32 --disable-nls --enable-languages=c,c++
--with-gmp=/compile/mingw/for_targe
t --enable-twoprocess --disable-libstdcxx-pch --prefix=/compile/mingw/target
--w
ith-sysroot=/compile/mingw/target
Thread model: win32
gcc version 4.5.0 20090421 (experimental) (GCC)


-- 
           Summary: program built by x86_64-pc-mingw32-gcc run crash, maybe
                    for _Unwind_SjLj_Unregister,
           Product: gcc
           Version: 4.5.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: libstdc++
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: drangon dot mail at gmail dot com
 GCC build triplet: x86_64-redhat-linux-gnu
  GCC host triplet: x86_64-pc-mingw32
GCC target triplet: x86_64-pc-mingw32


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=39832

Reply via email to