Path: utzoo!utgpu!jarvis.csri.toronto.edu!mailrus!tut.cis.ohio-state.edu!UCDAVIS.EDU!csusac!cvms!root From: csusac!cvms!root@UCDAVIS.EDU Newsgroups: gnu.g++.lib.bug Subject: Bug report for GNU Libg++ 1.35.1 on i386 Message-ID: <8908042143.AA07069@csusac.csus.edu> Date: 4 Aug 89 21:43:37 GMT Sender: daemon@tut.cis.ohio-state.edu Distribution: gnu Organization: GNUs Not Usenet Lines: 205 Bug report for GNU Libg++ 1.35.1 Machine: Cubix QB3/386 OS: System V/386 Release 3.2 (Cubix Id: 386-3/A/0) Config: g++-1.35.1-, config-g++ i386v (with my COFF patches) libg++-1.35.1, with certain System V and i386 patches (available on request) Problem: New streams implementation causes a bus error and dumps core. Here is relevant information: (I apologize for the assembly level debugging; -g isn't implemented for COFF yet, and -g0 is pretty sickly.) # make g++ -O -fchar-charconst -I../g++-include -I.. -fstrength-reduce -fsave-memoized -fno-defer-pop -c builtin.cc g++ -O -fchar-charconst -I../g++-include -I.. -fstrength-reduce -fsave-memoized -fno-defer-pop -c File.cc /usr/include/sys/fcntl.h:65: warning: type declaration of flock shadows previous declaration /usr/include/sys/fcntl.h:65: warning: `flock' was declared `extern' and later `static' In method struct File *File::File (int, char *, enum io_mode): File.cc:262: warning: assignment of unsigned pointer from signed pointer g++ -O -fchar-charconst -I../g++-include -I.. -fstrength-reduce -fsave-memoized -fno-defer-pop -c stream.cc g++ -O -fchar-charconst -I../g++-include -I.. -fstrength-reduce -fsave-memoized -fno-defer-pop -c streambuf.cc /usr/include/sys/fcntl.h:65: warning: type declaration of flock shadows previous declaration /usr/include/sys/fcntl.h:65: warning: `flock' was declared `extern' and later `static' In method void Filebuf::init_streambuf_ptrs (): streambuf.cc:233: warning: assignment of signed pointer from unsigned pointer In method int Filebuf::underflow (): streambuf.cc:352: warning: assignment of signed pointer from unsigned pointer streambuf.cc:361: warning: assignment of unsigned pointer from signed pointer In method int Filebuf::overflow (int (= -1 )): streambuf.cc:390: warning: assignment of signed pointer from unsigned pointer streambuf.cc:401: warning: assignment of unsigned pointer from signed pointer streambuf.cc:408: warning: assignment of signed pointer from unsigned pointer g++ -O -fchar-charconst -I../g++-include -I.. -fstrength-reduce -fsave-memoized -fno-defer-pop -c PlotFile.cc g++ -O -fchar-charconst -I../g++-include -I.. -fstrength-reduce -fsave-memoized -fno-defer-pop -c SFile.cc g++ -O -fchar-charconst -I../g++-include -I.. -fstrength-reduce -fsave-memoized -fno-defer-pop -c Obstack.cc gcc -g -O -I../g++-include -DUSG -c regex.c regex.c: In function re_search_2: regex.c:1069: warning: argument passing between incompatible pointer types regex.c:1069: warning: argument passing between incompatible pointer types regex.c: In function re_match: regex.c:1096: warning: argument passing between incompatible pointer types g++ -O -fchar-charconst -I../g++-include -I.. -fstrength-reduce -fsave-memoized -fno-defer-pop -c String.cc g++ -O -fchar-charconst -I../g++-include -I.. -fstrength-reduce -fsave-memoized -fno-defer-pop -c Integer.cc g++ -O -fchar-charconst -I../g++-include -I.. -fstrength-reduce -fsave-memoized -fno-defer-pop -c Rational.cc g++ -O -fchar-charconst -I../g++-include -I.. -fstrength-reduce -fsave-memoized -fno-defer-pop -c Complex.cc g++ -O -fchar-charconst -I../g++-include -I.. -fstrength-reduce -fsave-memoized -fno-defer-pop -c BitSet.cc g++ -O -fchar-charconst -I../g++-include -I.. -fstrength-reduce -fsave-memoized -fno-defer-pop -c BitString.cc g++ -O -fchar-charconst -I../g++-include -I.. -fstrength-reduce -fsave-memoized -fno-defer-pop -c Random.cc g++ -O -fchar-charconst -I../g++-include -I.. -fstrength-reduce -fsave-memoized -fno-defer-pop -c RNG.cc g++ -O -fchar-charconst -I../g++-include -I.. -fstrength-reduce -fsave-memoized -fno-defer-pop -c ACG.cc g++ -O -fchar-charconst -I../g++-include -I.. -fstrength-reduce -fsave-memoized -fno-defer-pop -c MLCG.cc g++ -O -fchar-charconst -I../g++-include -I.. -fstrength-reduce -fsave-memoized -fno-defer-pop -c Sample.cc g++ -O -fchar-charconst -I../g++-include -I.. -fstrength-reduce -fsave-memoized -fno-defer-pop -c Fix.cc g++ -O -fchar-charconst -I../g++-include -I.. -fstrength-reduce -fsave-memoized -fno-defer-pop -c Fix16.cc g++ -O -fchar-charconst -I../g++-include -I.. -fstrength-reduce -fsave-memoized -fno-defer-pop -c Fix24.cc g++ -O -fchar-charconst -I../g++-include -I.. -fstrength-reduce -fsave-memoized -fno-defer-pop -c CursesWindow.c In method int CursesWindow::scanw (const char *, ...): CursesWindow.c:48: warning: assignment of unsigned pointer from signed pointer In method int CursesWindow::mvscanw (int, int, const char *, ...): CursesWindow.c:64: warning: assignment of unsigned pointer from signed pointer ar r libg++.a builtin.o File.o stream.o streambuf.o PlotFile.o SFile.o Obstack.o regex.o String.o Integer.o Rational.o Complex.o BitSet.o BitString.o Random.o RNG.o ACG.o MLCG.o Sample.o Fix.o Fix16.o Fix24.o CursesWindow.o ar: creating libg++.a # cp libg++.a /lib # cd ../tests # make tFile g++ -g0 -O -fchar-charconst -I../g++-include -I. -fstrength-reduce -fno-defer-pop -c tFile.cc g++ tFile.o -o tFile # ./tFile Bus error - core dumped # gdb tFile core GDB 3.2, Copyright (C) 1988 Free Software Foundation, Inc. There is ABSOLUTELY NO WARRANTY for GDB; type "info warranty" for details. GDB is free software and you are welcome to distribute copies of it under certain conditions; type "info copying" to see the conditions. Reading symbol data from /usr/spool/uucppublic/libg++-1.35.1/tests/tFile...done. Type "help" for a list of commands. (gdb) bt #0 0x6f76 in sputs_PSstreambuf_PQI () #1 0x5bb in t1 () (tFile.cc line 32) #2 0x3fd2 in main (Error reading memory address 0x24d2196d: Not owner (1). (gdb) x/i $pc 0x6f76 : movb %cl,(%edx) (gdb) asdump Dump of assembler code from 0x6f2c to 0x6f8c: 0x6f2c : pushl %ebp 0x6f2d : movl %esp,%ebp 0x6f2f : pushl %edi 0x6f30 : pushl %esi 0x6f31 : pushl %ebx 0x6f32 : movl 8(%ebp),%edi 0x6f35 : movl 12(%ebp),%ebx 0x6f38 : testl %ebx,%ebx 0x6f3a : je 0x6f80 0x6f3c : cmpb $0x0,(%ebx) 0x6f3f : je 0x6f80 0x6f41 : leal 4(%edi),%esi 0x6f44 : movl 12(%edi),%ecx 0x6f47 : cmpl 4(%edi),%ecx 0x6f4a : ja 0x6f72 0x6f4c : movl 20(%edi),%eax 0x6f4f : movsbl (%ebx),%edx 0x6f52 : pushl %edx 0x6f53 : movswl 16(%eax),%edx 0x6f57 : leal (%edx,%edi,1),%edx 0x6f5a : pushl %edx 0x6f5b : movl 20(%eax),%eax 0x6f5e : call *%eax 0x6f60 : leal 8(%esp,1),%esp 0x6f64 : movl %eax,%edx 0x6f66 : cmpl $0xffffffff,%edx 0x6f69 : jne 0x6f7a 0x6f6b : movl $0xffffffff,%eax 0x6f70 : jmp 0x6f82 0x6f72 : movl (%esi),%edx 0x6f74 : movb (%ebx),%cl 0x6f76 : movb %cl,(%edx) 0x6f78 : incl (%esi) 0x6f7a : incl %ebx 0x6f7b : cmpb $0x0,(%ebx) 0x6f7e : jne 0x6f44 0x6f80 : xorl %eax,%eax 0x6f82 : leal -12(%ebp),%esp 0x6f85 : popl %ebx 0x6f86 : popl %esi 0x6f87 : popl %edi 0x6f88 : leave 0x6f89 : ret 0x6f8a : nop 0x6f8b : nop End of assembler dump. (gdb) q Here is the source merged with the assembler output. Make of it what you will. I am no 80386 assembler expert, but my first impression is that *pptr isn't pointing to the right thing when the instruction movb %cl,(%edx) [in the statement: *pptr++ = *s] is executed. #int streambuf::sputs(const char* s) .globl sputs_PSstreambuf_PQI sputs_PSstreambuf_PQI: #{ pushl %ebp movl %esp,%ebp pushl %edi pushl %esi pushl %ebx movl 8(%ebp),%edi movl 12(%ebp),%ebx # if (s != 0 ) testl %ebx,%ebx je .L422 # { # for(; *s != 0; ++s) cmpb $0,(%ebx) je .L422 leal 4(%edi),%esi .L429: # { # if (pptr < eptr) *pptr++ = *s; movl 12(%edi),%ecx cmpl 4(%edi),%ecx ja .L426 # else if (overflow(*s) == EOF) return EOF; movl 20(%edi),%eax movsbl (%ebx),%edx pushl %edx movswl 16(%eax),%edx leal (%edx,%edi),%edx pushl %edx movl 20(%eax),%eax call *%eax leal 8(%esp),%esp movl %eax,%edx cmpl $-1,%edx jne .L425 movl $-1,%eax jmp .L421 .L426: movl (%esi),%edx movb (%ebx),%cl movb %cl,(%edx) incl (%esi) # } # } .L425: incl %ebx cmpb $0,(%ebx) jne .L429 .L422: # return 0; xorl %eax,%eax #} .L421: leal -12(%ebp),%esp popl %ebx popl %esi popl %edi leave ret -- Ronald Cole | uucp: cvms!ronald voice: +1 916 895 8321 Senior Software Engineer | internet: csusac!cvms!ronald@ucdavis.edu CVM Systems +---------------------------------------------------- "SCCS, the source motel! Programs check in and never check out!" - Ken Thompson