Segmentation fault when using dynamic library and virtual methods with Gcc 2.95.2
Jacques.Herry@infineon.com
Jacques.Herry@infineon.com
Fri Oct 5 02:09:00 GMT 2001
GCC Version:
gcc version 2.95.2 19991024 (release)
with GNU assembler version 2.11.2 (sparc-sun-solaris2.5.1) using BFD version 2.11.2
GNU ld 2.11.2
Platform:
SunOS chablis 5.5.1 Generic_103640-36 sun4u sparc SUNW,Ultra-4
Bug description:
When a library containing class definitions with virtual method(s) is linked dynamically to a main program, a call to a dynamic method causes a segmentation fault (and a core dump).
Calling the virtual method in the main program (even in a never used function !!!!) or linking in static mode avoid this crash.
When compiling and linking the programs as follow, the execution crashes (segmentation fault).
When uncommenting the lines 113 and 114 of BugMain.cc and recompiling, the execution is correct.
When linking statically, the execution is correct.
When including content of SmsXxlExceptionsXCL.cc/hh and SmsXxlOverflowXCL.cc/hh in BugMain.cc, the exeution is correct.
Library make:
g++ -v -g -DSMS_DEBUG=1 -mcpu=v8 -Wall -pedantic -fPIC -c -o solrs251/GCC2952/dbg/dyn/SmsXxlExceptionsXCL.o SmsXxlExceptionsXCL.cc -I .
g++ -v -g -DSMS_DEBUG=1 -mcpu=v8 -Wall -pedantic -fPIC -c -o solrs251/GCC2952/dbg/dyn/SmsXxlOverflowXCL.o SmsXxlOverflowXCL.cc -I .
g++ -Wl,-E -v -shared -fPIC -o solrs251/GCC2952/dbg/libSmsXxl.so solrs251/GCC2952/dbg/dyn/SmsXxlExceptionsXCL.o solrs251/GCC2952/dbg/dyn/SmsXxlOverflowXCL.o
Executable make:
g++ -v -g -DSMS_DEBUG=1 -mcpu=v8 -Wall -pedantic -c -o solrs251/GCC2952/dbg/BugMain.o BugMain.cc -I.
g++ -fPIC -Wl,-E -v -o solrs251/GCC2952/dbg/BugMain.exe solrs251/GCC2952/dbg/BugMain.o -L/var/vob/softdev/Foundation/private/suites/Xxl/UnitTests/BUG_GCC_2/./solrs251/GCC2952/dbg -R/var/vob/softdev/Foundation/private/suites/Xxl/UnitTests/BUG_GCC_2/./solrs251/GCC2952/dbg -Wl,-Bdynamic -lSmsXxl
Content of attached tar-file:
SmsXxlExceptionsXCL.cc/hh : base class
SmsXxlOverflowXCL.cc/hh : derived class
These files are linked in shared mode
BugMain.cc : main program
make.log : make log file
Please let me know if you'd like more information.
Thanks.
Jacques Herry <Jacques.Herry@infineon.fr>
<<bug.tar>>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: bug.tar
Type: application/x-tar
Size: 24576 bytes
Desc: not available
URL: <http://gcc.gnu.org/pipermail/gcc-bugs/attachments/20011005/e98b629a/attachment.tar>
More information about the Gcc-bugs
mailing list