Hi Damir Damir Buskulic wrote: > > It's very nice you warn us. Could you be more specific, please. I'm > using -O2 on LinuxPPC R5 which is the equivalent of RedHat6.0 for > Macs. What is the exact problem, and could you give a simple script > that shows it, so I can try and see if it happens also on my mnachine? I am cross posting to the roottalk list in case others may want to test their systems for this bug as well. I have attached the files which I included in my original bug report to the egcs developers. To test if you might have the bug, then compile "test.cxx" with "g++ -O2". On my system this will create a program that will cause a core dump at run time due to a signal 11, Segmentation fault. If you inspect the program with gdb (making sure to specify the core file), and if you know Intel assembly (see the file test.s for the full, but tiny, assembler listing) then it will be obvious where the problem is (pow's exponent is being used as a register offset). -- Matthew D. Langston SLD, Stanford Linear Accelerator Center langston@SLAC.Stanford.EDU # -*- Makefile -*- VPATH = /mnt/hdc/projects/ROOT/2.00/root-bug/src CC = g++ CXX = g++ CXXFLAGS = -g -O2 -Wall .PHONY: check clean check: test ./test clean: rm -f test core a.out *.o *~ %.o: %.cxx $(CXX) -c $(CPPFLAGS) $(CXXFLAGS) -c $< -o $@ egcs 1.1.2 bug: stack corruption with "pow" and "-O2" I have found that g++ from egcs 1.1.2 produces bad assembly code when the "pow" function from glibc 2.1 is inlined (via the "-O2" optimization flag) in the same stack frame as a trivial C++ object which has a user defined default constructor and copy constructor. The following code reproduces this problem on my system: <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< begin example <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< #include <cmath> class Foo { Foo( const Foo& ); public: Foo() {} }; int main() { Foo foo; double m = pow( 1.0, 1.0 ); m = pow( m, 1.0 ); } >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> end example >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> Compiling this example on my system using "g++ -O2" will create a program that will cause a core dump at run time due to a signal 11, Segmentation fault. The interesting thing about this bug is that commenting out the private copy constructor makes the bug disappear. My system configuration is: Machine configuration with bug ------------------------------ RedHat Linux 6.0 Intel kernel 2.2.5 glibc 2.1.1 egcs 1.1.2 binutils 2.9.1.0.23 Here is the command line, and its output, used to create `test.ii' (which is attached below): langston@seto$ g++ -v --save-temps -O2 test.cxx Reading specs from /usr/lib/gcc-lib/i386-redhat-linux/egcs-2.91.66/specs gcc version egcs-2.91.66 19990314/Linux (egcs-1.1.2 release) /usr/lib/gcc-lib/i386-redhat-linux/egcs-2.91.66/cpp -lang-c++ -v -undef -D__GNUC__=2 -D__GNUG__=2 -D__cplusplus -D__GNUC_MINOR__=91 -D__ELF__ -Dunix -Di386 -D__i386__ -Dlinux -D__ELF__ -D__unix__ -D__i386__ -D__i386__ -D__linux__ -D__unix -D__i386 -D__linux -Asystem(posix) -D__EXCEPTIONS -D__OPTIMIZE__ -Asystem(unix) -Acpu(i386) -Amachine(i386) -Di386 -D__i386 -D__i386__ test.cxx test.ii GNU CPP version egcs-2.91.66 19990314/Linux (egcs-1.1.2 release) (i386 Linux/ELF) #include "..." search starts here: #include <...> search starts here: /usr/include/g++-2 /usr/i386-redhat-linux/include /usr/lib/gcc-lib/i386-redhat-linux/egcs-2.91.66/include /usr/include End of search list. /usr/lib/gcc-lib/i386-redhat-linux/egcs-2.91.66/cc1plus test.ii -quiet -dumpbase test.cc -O2 -version -o test.s GNU C++ version egcs-2.91.66 19990314/Linux (egcs-1.1.2 release) (i386-redhat-linux) compiled by GNU C version egcs-2.91.66 19990314/Linux (egcs-1.1.2 release). as -V -Qy -o test.o test.s GNU assembler version 2.9.1 (i386-redhat-linux), using BFD version 2.9.1.0.23 /usr/lib/gcc-lib/i386-redhat-linux/egcs-2.91.66/collect2 -m elf_i386 -dynamic-linker /lib/ld-linux.so.2 /usr/lib/crt1.o /usr/lib/crti.o /usr/lib/gcc-lib/i386-redhat-linux/egcs-2.91.66/crtbegin.o -L/usr/lib/gcc-lib/i386-redhat-linux/egcs-2.91.66 -L/usr/i386-redhat-linux/lib test.o -lstdc++ -lm -lgcc -lc -lgcc /usr/lib/gcc-lib/i386-redhat-linux/egcs-2.91.66/crtend.o /usr/lib/crtn.o langston@seto$ -- Matthew D. Langston SLD, Stanford Linear Accelerator Center langston@SLAC.Stanford.EDU #include <cmath> class Foo { Foo( const Foo& ); public: Foo() {} }; int main() { Foo foo; double m = pow( 1.0, 1.0 ); m = pow( m, 1.0 ); }
This archive was generated by hypermail 2b29 : Tue Jan 04 2000 - 00:43:35 MET