root@UCDAVIS.EDU (08/05/89)
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 <sputs_PSstreambuf_PQI+74>: movb %cl,(%edx) (gdb) asdump Dump of assembler code from 0x6f2c to 0x6f8c: 0x6f2c <sputs_PSstreambuf_PQI>: pushl %ebp 0x6f2d <sputs_PSstreambuf_PQI+1>: movl %esp,%ebp 0x6f2f <sputs_PSstreambuf_PQI+3>: pushl %edi 0x6f30 <sputs_PSstreambuf_PQI+4>: pushl %esi 0x6f31 <sputs_PSstreambuf_PQI+5>: pushl %ebx 0x6f32 <sputs_PSstreambuf_PQI+6>: movl 8(%ebp),%edi 0x6f35 <sputs_PSstreambuf_PQI+9>: movl 12(%ebp),%ebx 0x6f38 <sputs_PSstreambuf_PQI+12>: testl %ebx,%ebx 0x6f3a <sputs_PSstreambuf_PQI+14>: je 0x6f80 0x6f3c <sputs_PSstreambuf_PQI+16>: cmpb $0x0,(%ebx) 0x6f3f <sputs_PSstreambuf_PQI+19>: je 0x6f80 0x6f41 <sputs_PSstreambuf_PQI+21>: leal 4(%edi),%esi 0x6f44 <sputs_PSstreambuf_PQI+24>: movl 12(%edi),%ecx 0x6f47 <sputs_PSstreambuf_PQI+27>: cmpl 4(%edi),%ecx 0x6f4a <sputs_PSstreambuf_PQI+30>: ja 0x6f72 0x6f4c <sputs_PSstreambuf_PQI+32>: movl 20(%edi),%eax 0x6f4f <sputs_PSstreambuf_PQI+35>: movsbl (%ebx),%edx 0x6f52 <sputs_PSstreambuf_PQI+38>: pushl %edx 0x6f53 <sputs_PSstreambuf_PQI+39>: movswl 16(%eax),%edx 0x6f57 <sputs_PSstreambuf_PQI+43>: leal (%edx,%edi,1),%edx 0x6f5a <sputs_PSstreambuf_PQI+46>: pushl %edx 0x6f5b <sputs_PSstreambuf_PQI+47>: movl 20(%eax),%eax 0x6f5e <sputs_PSstreambuf_PQI+50>: call *%eax 0x6f60 <sputs_PSstreambuf_PQI+52>: leal 8(%esp,1),%esp 0x6f64 <sputs_PSstreambuf_PQI+56>: movl %eax,%edx 0x6f66 <sputs_PSstreambuf_PQI+58>: cmpl $0xffffffff,%edx 0x6f69 <sputs_PSstreambuf_PQI+61>: jne 0x6f7a 0x6f6b <sputs_PSstreambuf_PQI+63>: movl $0xffffffff,%eax 0x6f70 <sputs_PSstreambuf_PQI+68>: jmp 0x6f82 0x6f72 <sputs_PSstreambuf_PQI+70>: movl (%esi),%edx 0x6f74 <sputs_PSstreambuf_PQI+72>: movb (%ebx),%cl 0x6f76 <sputs_PSstreambuf_PQI+74>: movb %cl,(%edx) 0x6f78 <sputs_PSstreambuf_PQI+76>: incl (%esi) 0x6f7a <sputs_PSstreambuf_PQI+78>: incl %ebx 0x6f7b <sputs_PSstreambuf_PQI+79>: cmpb $0x0,(%ebx) 0x6f7e <sputs_PSstreambuf_PQI+82>: jne 0x6f44 0x6f80 <sputs_PSstreambuf_PQI+84>: xorl %eax,%eax 0x6f82 <sputs_PSstreambuf_PQI+86>: leal -12(%ebp),%esp 0x6f85 <sputs_PSstreambuf_PQI+89>: popl %ebx 0x6f86 <sputs_PSstreambuf_PQI+90>: popl %esi 0x6f87 <sputs_PSstreambuf_PQI+91>: popl %edi 0x6f88 <sputs_PSstreambuf_PQI+92>: leave 0x6f89 <sputs_PSstreambuf_PQI+93>: ret 0x6f8a <sputs_PSstreambuf_PQI+94>: nop 0x6f8b <sputs_PSstreambuf_PQI+95>: 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