public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/13654] New: multiple translation units, inlined constructor: invalid vtable [cygwin 3.3.1]
@ 2004-01-12 11:40 gcc at axel-naumann dot de
  2004-01-12 11:49 ` [Bug c++/13654] " gcc at axel-naumann dot de
                   ` (8 more replies)
  0 siblings, 9 replies; 10+ messages in thread
From: gcc at axel-naumann dot de @ 2004-01-12 11:40 UTC (permalink / raw)
  To: gcc-bugs

A header declaring a class with an inlined constructor is included in the
sources used to build a shared lib, and in those used to build a binary linked
against the lib. This will result in a core dump when the binary calls a class's
method defined in the library. It only happens with a call on a heap object, not
on a stack object.

Only happens on cygwin with vers. 3.3.1, not with vers. 3.2, not on linux.

Assumption: in the case of inlined constructors, a separate vtable is created
for each translation unit.

[example sources follow]
[this bug report replaces the incorrect & invalidated report #13463]

-- 
           Summary: multiple translation units, inlined constructor: invalid
                    vtable [cygwin 3.3.1]
           Product: gcc
           Version: 3.3.1
            Status: UNCONFIRMED
          Severity: normal
          Priority: P2
         Component: c++
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: gcc at axel-naumann dot de
                CC: gcc-bugs at gcc dot gnu dot org
 GCC build triplet: i686-pc-cygwin
  GCC host triplet: i686-pc-cygwin
GCC target triplet: i686-pc-cygwin


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


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

* [Bug c++/13654] multiple translation units, inlined constructor: invalid vtable [cygwin 3.3.1]
  2004-01-12 11:40 [Bug c++/13654] New: multiple translation units, inlined constructor: invalid vtable [cygwin 3.3.1] gcc at axel-naumann dot de
@ 2004-01-12 11:49 ` gcc at axel-naumann dot de
  2004-01-12 15:56 ` pinskia at gcc dot gnu dot org
                   ` (7 subsequent siblings)
  8 siblings, 0 replies; 10+ messages in thread
From: gcc at axel-naumann dot de @ 2004-01-12 11:49 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From gcc at axel-naumann dot de  2004-01-12 11:49 -------
Created an attachment (id=5460)
 --> (http://gcc.gnu.org/bugzilla/attachment.cgi?id=5460&action=view)
test case, incl. stripped sources

(Relevant) output of the build.sh script. Shell level calls are marked with
"+". See *.stripped.ii for the stripped preprocessed sources.

$ ./build.sh
+ g++ -v -save-temps -c -g -Wall -Woverloaded-virtual -D_DLL -D_REENTRANT
lib.cpp
Reading specs from /usr/lib/gcc-lib/i686-pc-cygwin/3.3.1/specs
Configured with: /GCC/gcc-3.3.1-3/configure --with-gcc --with-gnu-ld
--with-gnu-as --prefix=/usr --exec-prefix=/usr --sysconfdir=/etc
--libdir=/usr/lib --libexecdir=/usr/sbin --mandir=/usr/share/man
--infodir=/usr/share/info --enable-languages=c,ada,c++,f77,pascal,java,objc
--enable-libgcj --enable-threads=posix --with-system-zlib --enable-nls
--without-included-gettext --enable-interpreter --enable-sjlj-exceptions
--disable-version-specific-runtime-libs --enable-shared
--disable-win32-registry --enable-java-gc=boehm --disable-hash-synchronization
--verbose --target=i686-pc-cygwin --host=i686-pc-cygwin --build=i686-pc-cygwin
Thread model: posix
gcc version 3.3.1 (cygming special)
 /usr/lib/gcc-lib/i686-pc-cygwin/3.3.1/cc1plus.exe -E -D__GNUG__=3 -quiet -v
-D__GNUC__=3 -D__GNUC_MINOR__=3 -D__GNUC_PATCHLEVEL__=1 -D__CYGWIN32__
-D__CYGWIN__ -Dunix -D__unix__ -D__unix -idirafter 
/usr/lib/gcc-lib/i686-pc-cygwin/3.3.1/../
../../../include/w32api -idirafter
/usr/lib/gcc-lib/i686-pc-cygwin/3.3.1/../../../../i686-pc-cygwin/lib/../../include/w32api
-D_DLL -D_REENTRANT lib.cpp -Wall -Woverloaded-virtual lib.ii
ignoring nonexistent directory "/usr/i686-pc-cygwin/include"
ignoring duplicate directory "/usr/i686-pc-cygwin/lib/../../include/w32api"
#include "..." search starts here:
#include <...> search starts here:
 /usr/include/c++/3.3.1
 /usr/include/c++/3.3.1/i686-pc-cygwin
 /usr/include/c++/3.3.1/backward
 /usr/local/include
 /usr/lib/gcc-lib/i686-pc-cygwin/3.3.1/include
 /usr/include
 /usr/include/w32api
End of search list.
 /usr/lib/gcc-lib/i686-pc-cygwin/3.3.1/cc1plus.exe -fpreprocessed lib.ii -quiet
-dumpbase lib.cpp -auxbase lib -g -Wall -Woverloaded-virtual -version -o lib.s
GNU C++ version 3.3.1 (cygming special) (i686-pc-cygwin)
	compiled by GNU C version 3.3.1 (cygming special).
GGC heuristics: --param ggc-min-expand=64 --param ggc-min-heapsize=65406
 /usr/lib/gcc-lib/i686-pc-cygwin/3.3.1/../../../../i686-pc-cygwin/bin/as.exe
--traditional-format -o lib.o lib.s
+ g++ -g -shared -o liblib.dll lib.o
+ g++ -v -save-temps -c -g -Wall -Woverloaded-virtual -D_DLL -D_REENTRANT
main.cpp
Reading specs from /usr/lib/gcc-lib/i686-pc-cygwin/3.3.1/specs
Configured with: /GCC/gcc-3.3.1-3/configure --with-gcc --with-gnu-ld
--with-gnu-as --prefix=/usr --exec-prefix=/usr --sysconfdir=/etc
--libdir=/usr/lib --libexecdir=/usr/sbin --mandir=/usr/share/man
--infodir=/usr/share/info --enable-languages=c,ada,c++,f77,pascal,java,objc
--enable-libgcj --enable-threads=posix --with-system-zlib --enable-nls
--without-included-gettext --enable-interpreter --enable-sjlj-exceptions
--disable-version-specific-runtime-libs --enable-shared
--disable-win32-registry --enable-java-gc=boehm --disable-hash-synchronization
--verbose --target=i686-pc-cygwin --host=i686-pc-cygwin --build=i686-pc-cygwin
Thread model: posix
gcc version 3.3.1 (cygming special)
 /usr/lib/gcc-lib/i686-pc-cygwin/3.3.1/cc1plus.exe -E -D__GNUG__=3 -quiet -v
-D__GNUC__=3 -D__GNUC_MINOR__=3 -D__GNUC_PATCHLEVEL__=1 -D__CYGWIN32__
-D__CYGWIN__ -Dunix -D__unix__ -D__unix -idirafter
/usr/lib/gcc-lib/i686-pc-cygwin/3.3.1/../
../../../include/w32api -idirafter
/usr/lib/gcc-lib/i686-pc-cygwin/3.3.1/../../../../i686-pc-cygwin/lib/../../include/w32api
-D_DLL -D_REENTRANT main.cpp -Wall -Woverloaded-virtual main.ii
ignoring nonexistent directory "/usr/i686-pc-cygwin/include"
ignoring duplicate directory "/usr/i686-pc-cygwin/lib/../../include/w32api"
#include "..." search starts here:
#include <...> search starts here:
 /usr/include/c++/3.3.1
 /usr/include/c++/3.3.1/i686-pc-cygwin
 /usr/include/c++/3.3.1/backward
 /usr/local/include
 /usr/lib/gcc-lib/i686-pc-cygwin/3.3.1/include
 /usr/include
 /usr/include/w32api
End of search list.
 /usr/lib/gcc-lib/i686-pc-cygwin/3.3.1/cc1plus.exe -fpreprocessed main.ii
-quiet -dumpbase main.cpp -auxbase main -g -Wall -Woverloaded-virtual -version
-o main.s
GNU C++ version 3.3.1 (cygming special) (i686-pc-cygwin)
	compiled by GNU C version 3.3.1 (cygming special).
GGC heuristics: --param ggc-min-expand=64 --param ggc-min-heapsize=65406
 /usr/lib/gcc-lib/i686-pc-cygwin/3.3.1/../../../../i686-pc-cygwin/bin/as.exe
--traditional-format -o main.o main.s
+ g++ -g -o vtbl main.o -L./ -llib
+ ./vtbl
alive
./build.sh: line 7:  2680 Segmentation fault	  (core dumped) ./vtbl


-- 


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


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

* [Bug c++/13654] multiple translation units, inlined constructor: invalid vtable [cygwin 3.3.1]
  2004-01-12 11:40 [Bug c++/13654] New: multiple translation units, inlined constructor: invalid vtable [cygwin 3.3.1] gcc at axel-naumann dot de
  2004-01-12 11:49 ` [Bug c++/13654] " gcc at axel-naumann dot de
@ 2004-01-12 15:56 ` pinskia at gcc dot gnu dot org
  2004-01-12 18:16 ` [Bug target/13654] " pinskia at gcc dot gnu dot org
                   ` (6 subsequent siblings)
  8 siblings, 0 replies; 10+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2004-01-12 15:56 UTC (permalink / raw)
  To: gcc-bugs



-- 
           What    |Removed                     |Added
----------------------------------------------------------------------------
           Keywords|                            |wrong-code


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


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

* [Bug target/13654] multiple translation units, inlined constructor: invalid vtable [cygwin 3.3.1]
  2004-01-12 11:40 [Bug c++/13654] New: multiple translation units, inlined constructor: invalid vtable [cygwin 3.3.1] gcc at axel-naumann dot de
  2004-01-12 11:49 ` [Bug c++/13654] " gcc at axel-naumann dot de
  2004-01-12 15:56 ` pinskia at gcc dot gnu dot org
@ 2004-01-12 18:16 ` pinskia at gcc dot gnu dot org
  2004-01-12 21:41 ` gcc at axel-naumann dot de
                   ` (5 subsequent siblings)
  8 siblings, 0 replies; 10+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2004-01-12 18:16 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From pinskia at gcc dot gnu dot org  2004-01-12 18:16 -------
Most likely not a gcc bug but rather a dynamic loader one and a GCC just cannot happen this case, 
note on Darwin which also does not support weak symbols works correctly on the mainline.

-- 
           What    |Removed                     |Added
----------------------------------------------------------------------------
          Component|c++                         |target


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


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

* [Bug target/13654] multiple translation units, inlined constructor: invalid vtable [cygwin 3.3.1]
  2004-01-12 11:40 [Bug c++/13654] New: multiple translation units, inlined constructor: invalid vtable [cygwin 3.3.1] gcc at axel-naumann dot de
                   ` (2 preceding siblings ...)
  2004-01-12 18:16 ` [Bug target/13654] " pinskia at gcc dot gnu dot org
@ 2004-01-12 21:41 ` gcc at axel-naumann dot de
  2004-01-13  5:53 ` pinskia at gcc dot gnu dot org
                   ` (4 subsequent siblings)
  8 siblings, 0 replies; 10+ messages in thread
From: gcc at axel-naumann dot de @ 2004-01-12 21:41 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From gcc at axel-naumann dot de  2004-01-12 21:41 -------
(In reply to comment #2)
> Most likely not a gcc bug but rather a dynamic loader one and a GCC just
cannot happen this case, 

I'm surprised that the cygwin dyn loader is the cause, as the issue disappears
1) with stackObj.method() instead of heapObj->method(),
2) or with gcc 3.2 (same cygwin, same binutils as with 3.3.1)

-- 


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


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

* [Bug target/13654] multiple translation units, inlined constructor: invalid vtable [cygwin 3.3.1]
  2004-01-12 11:40 [Bug c++/13654] New: multiple translation units, inlined constructor: invalid vtable [cygwin 3.3.1] gcc at axel-naumann dot de
                   ` (3 preceding siblings ...)
  2004-01-12 21:41 ` gcc at axel-naumann dot de
@ 2004-01-13  5:53 ` pinskia at gcc dot gnu dot org
  2004-01-13 15:32 ` gcc at axel-naumann dot de
                   ` (3 subsequent siblings)
  8 siblings, 0 replies; 10+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2004-01-13  5:53 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From pinskia at gcc dot gnu dot org  2004-01-13 05:53 -------
Can you try 3.3.2?

-- 


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


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

* [Bug target/13654] multiple translation units, inlined constructor: invalid vtable [cygwin 3.3.1]
  2004-01-12 11:40 [Bug c++/13654] New: multiple translation units, inlined constructor: invalid vtable [cygwin 3.3.1] gcc at axel-naumann dot de
                   ` (4 preceding siblings ...)
  2004-01-13  5:53 ` pinskia at gcc dot gnu dot org
@ 2004-01-13 15:32 ` gcc at axel-naumann dot de
  2004-01-14  2:59 ` dannysmith at gcc dot gnu dot org
                   ` (2 subsequent siblings)
  8 siblings, 0 replies; 10+ messages in thread
From: gcc at axel-naumann dot de @ 2004-01-13 15:32 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From gcc at axel-naumann dot de  2004-01-13 15:32 -------
(In reply to comment #4)
> Can you try 3.3.2?

Same result; the issue is reproducible with 3.3.2, too.

-- 


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


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

* [Bug target/13654] multiple translation units, inlined constructor: invalid vtable [cygwin 3.3.1]
  2004-01-12 11:40 [Bug c++/13654] New: multiple translation units, inlined constructor: invalid vtable [cygwin 3.3.1] gcc at axel-naumann dot de
                   ` (5 preceding siblings ...)
  2004-01-13 15:32 ` gcc at axel-naumann dot de
@ 2004-01-14  2:59 ` dannysmith at gcc dot gnu dot org
  2004-01-14  3:02 ` pinskia at gcc dot gnu dot org
  2004-01-14 14:53 ` gcc at axel-naumann dot de
  8 siblings, 0 replies; 10+ messages in thread
From: dannysmith at gcc dot gnu dot org @ 2004-01-14  2:59 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From dannysmith at gcc dot gnu dot org  2004-01-14 02:59 -------
This is YA dllimport problem.  Your testcase works for me (no segfault, app 
runs as expected) on mingw32 gcc-3.4 if I add
-Wl,--enable-runtime-pseudo-reloc to flags when building .exe
eg 
g++ -g -o vtbl main.o -Wl,--enable-runtime-pseudo-reloc -L./ -llib

Please read up auto-import section in ld.info to see why this is needed.
Danny

-- 


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


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

* [Bug target/13654] multiple translation units, inlined constructor: invalid vtable [cygwin 3.3.1]
  2004-01-12 11:40 [Bug c++/13654] New: multiple translation units, inlined constructor: invalid vtable [cygwin 3.3.1] gcc at axel-naumann dot de
                   ` (6 preceding siblings ...)
  2004-01-14  2:59 ` dannysmith at gcc dot gnu dot org
@ 2004-01-14  3:02 ` pinskia at gcc dot gnu dot org
  2004-01-14 14:53 ` gcc at axel-naumann dot de
  8 siblings, 0 replies; 10+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2004-01-14  3:02 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From pinskia at gcc dot gnu dot org  2004-01-14 03:02 -------
Not a GCC bug.

-- 
           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |RESOLVED
         Resolution|                            |INVALID


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


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

* [Bug target/13654] multiple translation units, inlined constructor: invalid vtable [cygwin 3.3.1]
  2004-01-12 11:40 [Bug c++/13654] New: multiple translation units, inlined constructor: invalid vtable [cygwin 3.3.1] gcc at axel-naumann dot de
                   ` (7 preceding siblings ...)
  2004-01-14  3:02 ` pinskia at gcc dot gnu dot org
@ 2004-01-14 14:53 ` gcc at axel-naumann dot de
  8 siblings, 0 replies; 10+ messages in thread
From: gcc at axel-naumann dot de @ 2004-01-14 14:53 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From gcc at axel-naumann dot de  2004-01-14 14:53 -------
(In reply to comment #6)
> This is YA dllimport problem.  Your testcase works for me (no segfault, app 
> runs as expected) on mingw32 gcc-3.4 if I add
> -Wl,--enable-runtime-pseudo-reloc to flags when building .exe
> eg 
> g++ -g -o vtbl main.o -Wl,--enable-runtime-pseudo-reloc -L./ -llib
> 
> Please read up auto-import section in ld.info to see why this is needed.

For the archives: --enable-runtime-pseudo-reloc doesn't solve it for gcc3.3.1's
ld. Instead, import libs (.dll.a) have to be created (--out-implib) for
gcc3.3.*'s ld again (wasn't needed for 3.2).

Thanks for your help with this!
Axel.

-- 


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


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

end of thread, other threads:[~2004-01-14 14:53 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2004-01-12 11:40 [Bug c++/13654] New: multiple translation units, inlined constructor: invalid vtable [cygwin 3.3.1] gcc at axel-naumann dot de
2004-01-12 11:49 ` [Bug c++/13654] " gcc at axel-naumann dot de
2004-01-12 15:56 ` pinskia at gcc dot gnu dot org
2004-01-12 18:16 ` [Bug target/13654] " pinskia at gcc dot gnu dot org
2004-01-12 21:41 ` gcc at axel-naumann dot de
2004-01-13  5:53 ` pinskia at gcc dot gnu dot org
2004-01-13 15:32 ` gcc at axel-naumann dot de
2004-01-14  2:59 ` dannysmith at gcc dot gnu dot org
2004-01-14  3:02 ` pinskia at gcc dot gnu dot org
2004-01-14 14:53 ` gcc at axel-naumann dot de

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