This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
Fwd: c++/3947 (destructor is called twice)
- To: gcc-gnats at gcc dot gnu dot org;, gcc-prs at gcc dot gnu dot org;,rodrigc at gcc dot gnu dot org;, gcc-bugs at gcc dot gnu dot org;, nobody at gcc dot gnu dot org;,simong at oz dot agile dot tv
- Subject: Fwd: c++/3947 (destructor is called twice)
- From: David Hanney <dh at digitalbrain dot com>
- Date: Tue, 23 Oct 2001 11:03:54 +0100
- Cc: debian-gcc at lists dot debian dot org, tim at digitalbrain dot com
on this venison of GCC ...
>tim@fum:~$ g++-3.0 -v
>Reading specs from /usr/lib/gcc-lib/i386-linux/3.0.2/specs
>Configured with: ../src/configure -v
>--enable-languages=c,c++,java,f77,proto,objc --prefix=/usr
>--infodir=/share/info --mandir=/share/man --enable-shared --with-gnu-as
>--with-gnu-ld --with-system-zlib --enable-long-long --enable-nls
>--without-included-gettext --disable-checking --enable-threads=posix
>--enable-java-gc=boehm --with-cpp-install-dir=bin --enable-objc-gc i386-linux
>Thread model: posix
>gcc version 3.0.2 20010922 (Debian prerelease)
>tim@fum:~$ uname -a
>Linux fum 2.4.12-VLAN #2 SMP Mon Oct 15 10:20:08 BST 2001 i686 unknown
I'm getting a similar problem to
http://gcc.gnu.org/cgi-bin/gnatsweb.pl?cmd=view&pr=3947
(and reverting to compiling with 2.95.2 'fixes' it)
It makes a thunk that contains an extra destructor.
There is no matching constructor.
So the destructor is called twice.
Here is the function...
(no problems here)
(see annotations starting with '^')
Dump of assembler code for function _ZN9FileStore7SetPathE6String:
0x405ea240 <_ZN9FileStore7SetPathE6String>: push %ebp
0x405ea241 <_ZN9FileStore7SetPathE6String+1>: mov %esp,%ebp
0x405ea243 <_ZN9FileStore7SetPathE6String+3>: push %ebx
0x405ea244 <_ZN9FileStore7SetPathE6String+4>: sub $0x14,%esp
0x405ea247 <_ZN9FileStore7SetPathE6String+7>: sub $0x8,%esp
^ (btw GDB says the function is here)
0x405ea24a <_ZN9FileStore7SetPathE6String+10>: pushl 0xc(%ebp)
0x405ea24d <_ZN9FileStore7SetPathE6String+13>: mov 0x8(%ebp),%eax
0x405ea250 <_ZN9FileStore7SetPathE6String+16>: add $0x4,%eax
0x405ea253 <_ZN9FileStore7SetPathE6String+19>: push %eax
0x405ea254 <_ZN9FileStore7SetPathE6String+20>:
call 0x405b0b54 <_ZN6StringaSERKS_>
^ construction (fine!)
0x405ea259 <_ZN9FileStore7SetPathE6String+25>: add $0x10,%esp
0x405ea25c <_ZN9FileStore7SetPathE6String+28>: sub $0x8,%esp
0x405ea25f <_ZN9FileStore7SetPathE6String+31>: pushl 0xc(%ebp)
0x405ea262 <_ZN9FileStore7SetPathE6String+34>: mov 0x8(%ebp),%eax
0x405ea265 <_ZN9FileStore7SetPathE6String+37>: add $0xc,%eax
0x405ea268 <_ZN9FileStore7SetPathE6String+40>: push %eax
0x405ea269 <_ZN9FileStore7SetPathE6String+41>:
call 0x405ea734 <_ZN7FileOps7SetPathERK6String>
0x405ea26e <_ZN9FileStore7SetPathE6String+46>: add $0x10,%esp
0x405ea271 <_ZN9FileStore7SetPathE6String+49>: sub $0xc,%esp
0x405ea274 <_ZN9FileStore7SetPathE6String+52>: pushl 0xc(%ebp)
0x405ea277 <_ZN9FileStore7SetPathE6String+55>:
call 0x405ae688 <_ZN6StringD1Ev>
^ matching destruction (fine!)
0x405ea27c <_ZN9FileStore7SetPathE6String+60>: add $0x10,%esp
0x405ea27f <_ZN9FileStore7SetPathE6String+63>:
jmp 0x405ea2a8 <_ZN9FileStore7SetPathE6String+104>
0x405ea281 <_ZN9FileStore7SetPathE6String+65>: lea 0x0(%esi),%esi
0x405ea284 <_ZN9FileStore7SetPathE6String+68>: mov %eax,0xfffffff8(%ebp)
0x405ea287 <_ZN9FileStore7SetPathE6String+71>: mov 0xfffffff8(%ebp),%ebx
0x405ea28a <_ZN9FileStore7SetPathE6String+74>: sub $0xc,%esp
0x405ea28d <_ZN9FileStore7SetPathE6String+77>: pushl 0xc(%ebp)
0x405ea290 <_ZN9FileStore7SetPathE6String+80>:
call 0x405ae688 <_ZN6StringD1Ev>
0x405ea295 <_ZN9FileStore7SetPathE6String+85>: add $0x10,%esp
0x405ea298 <_ZN9FileStore7SetPathE6String+88>: mov %ebx,0xfffffff8(%ebp)
0x405ea29b <_ZN9FileStore7SetPathE6String+91>: sub $0xc,%esp
0x405ea29e <_ZN9FileStore7SetPathE6String+94>: pushl 0xfffffff8(%ebp)
0x405ea2a1 <_ZN9FileStore7SetPathE6String+97>: call 0x4093f400
0x405ea2a6 <_ZN9FileStore7SetPathE6String+102>: mov %esi,%esi
0x405ea2a8 <_ZN9FileStore7SetPathE6String+104>: mov 0xfffffffc(%ebp),%ebx
0x405ea2ab <_ZN9FileStore7SetPathE6String+107>: leave
0x405ea2ac <_ZN9FileStore7SetPathE6String+108>: ret
Here is the bogus thunk ...
(see annotations starting with '^')
Dump of assembler code for function _ZTv0_n28_N9FileStore7SetPathE6String:
0x405ea1e0 <_ZTv0_n28_N9FileStore7SetPathE6String>: push %ebp
0x405ea1e1 <_ZTv0_n28_N9FileStore7SetPathE6String+1>: mov %esp,%ebp
0x405ea1e3 <_ZTv0_n28_N9FileStore7SetPathE6String+3>: push %ebx
0x405ea1e4 <_ZTv0_n28_N9FileStore7SetPathE6String+4>: sub $0x14,%esp
0x405ea1e7 <_ZTv0_n28_N9FileStore7SetPathE6String+7>: sub $0x8,%esp
0x405ea1ea <_ZTv0_n28_N9FileStore7SetPathE6String+10>: pushl 0xc(%ebp)
0x405ea1ed <_ZTv0_n28_N9FileStore7SetPathE6String+13>: mov 0x8(%ebp),%eax
0x405ea1f0 <_ZTv0_n28_N9FileStore7SetPathE6String+16>: mov (%eax),%edx
0x405ea1f2 <_ZTv0_n28_N9FileStore7SetPathE6String+18>: sub $0x1c,%edx
0x405ea1f5 <_ZTv0_n28_N9FileStore7SetPathE6String+21>: mov 0x8(%ebp),%eax
0x405ea1f8 <_ZTv0_n28_N9FileStore7SetPathE6String+24>: add (%edx),%eax
0x405ea1fa <_ZTv0_n28_N9FileStore7SetPathE6String+26>: push %eax
0x405ea1fb <_ZTv0_n28_N9FileStore7SetPathE6String+27>:
call 0x405ea240 <_ZN9FileStore7SetPathE6String>
^ this is where the thunk calls the real function
0x405ea200 <_ZTv0_n28_N9FileStore7SetPathE6String+32>: add $0x10,%esp
0x405ea203 <_ZTv0_n28_N9FileStore7SetPathE6String+35>: sub $0xc,%esp
0x405ea206 <_ZTv0_n28_N9FileStore7SetPathE6String+38>: pushl 0xc(%ebp)
0x405ea209 <_ZTv0_n28_N9FileStore7SetPathE6String+41>:
call 0x405ae688 <_ZN6StringD1Ev>
^ what is this doing in the thunk?
^ where it the corresponding constructor called?
^ (clue: it isn't!)
0x405ea20e <_ZTv0_n28_N9FileStore7SetPathE6String+46>: add $0x10,%esp
0x405ea211 <_ZTv0_n28_N9FileStore7SetPathE6String+49>:
jmp 0x405ea238 <_ZTv0_n28_N9FileStore7SetPathE6String+88>
0x405ea213 <_ZTv0_n28_N9FileStore7SetPathE6String+51>: nop
0x405ea214 <_ZTv0_n28_N9FileStore7SetPathE6String+52>:
mov %eax,0xfffffff8(%ebp)
0x405ea217 <_ZTv0_n28_N9FileStore7SetPathE6String+55>:
mov 0xfffffff8(%ebp),%ebx
0x405ea21a <_ZTv0_n28_N9FileStore7SetPathE6String+58>: sub $0xc,%esp
0x405ea21d <_ZTv0_n28_N9FileStore7SetPathE6String+61>: pushl 0xc(%ebp)
0x405ea220 <_ZTv0_n28_N9FileStore7SetPathE6String+64>:
call 0x405ae688 <_ZN6StringD1Ev>
0x405ea225 <_ZTv0_n28_N9FileStore7SetPathE6String+69>: add $0x10,%esp
0x405ea228 <_ZTv0_n28_N9FileStore7SetPathE6String+72>:
mov %ebx,0xfffffff8(%ebp)
0x405ea22b <_ZTv0_n28_N9FileStore7SetPathE6String+75>: sub $0xc,%esp
0x405ea22e <_ZTv0_n28_N9FileStore7SetPathE6String+78>: pushl 0xfffffff8(%ebp)
0x405ea231 <_ZTv0_n28_N9FileStore7SetPathE6String+81>: call 0x4093f400
0x405ea236 <_ZTv0_n28_N9FileStore7SetPathE6String+86>: mov %esi,%esi
0x405ea238 <_ZTv0_n28_N9FileStore7SetPathE6String+88>:
mov 0xfffffffc(%ebp),%ebx
0x405ea23b <_ZTv0_n28_N9FileStore7SetPathE6String+91>: leave
0x405ea23c <_ZTv0_n28_N9FileStore7SetPathE6String+92>: ret
End of assembler dump.
Do let me know if there is any more information we can provide to help fix
this!
Best Regards,
DH
--------------------------------------
David Hanney
Chief Technical Officer
http://www.digitalbrain.com
[UK+44] (0)1273 201704