Subject: Re: Bug in fstream code and gcc-2 package?
From: Beman Dawes <[email-masked]>
To: <[email-masked]>
Cc: "John Maddock" <[email-masked]>
Date: Sat, 03 Jan 2004 20:55:52 -0500

At 04:12 PM 1/3/2004, Gerrit P. Haase wrote:

 >Hallo Beman,
 >
 >I cannot reproduce it here on my NT4 SP 6a:

John Maddock can't reproduce it on his system either.

First, my results for the queries below are shown after your results:

 >$ uname -svr
 >CYGWIN_NT-4.0 1.5.5(0.94/3/2) 2003-09-20 16:31

CYGWIN_NT-5.1 1.5.5(0.94/3/2) 2003-09-20 16:31

 >$ cygcheck -c gcc
 >Cygwin Package Information
 >Package              Version        Status
 >gcc                  3.3.1-3        OK
gcc                  3.3.1-3        OK

 >$ cygcheck -c gcc-g++
 >Cygwin Package Information
 >Package              Version        Status
 >gcc-g++              3.3.1-3        OK
gcc-g++              3.3.1-3        OK

 >$ g++ fstream.cpp
 >$ ls
 >a.exe*  fstream.cpp
 >$ ./a
       2 [main] a 1228 handle_exceptions: Exception: 
STATUS_ACCESS_VIOLATION
     327 [main] a 1228 open_stackdumpfile: Dumping stack trace to 
a.exe.stackdump
 >$ cygcheck a
 >Found: .\a.exe
 >a.exe
 >  H:\bin\cygwin1.dll
 >    C:\WINNT\System32\KERNEL32.dll
 >      C:\WINNT\System32\ntdll.dll
Found: .\a.exe
a.exe
   c:\cygwin\bin\cygwin1.dll
     C:\WINDOWS\System32\KERNEL32.dll
       C:\WINDOWS\System32\ntdll.dll
 >$ g++ -mno-cygwin fstream.cpp
In file included from 
/usr/local/include/c++/3.3.1/bits/locale_facets.h:166,
                  from /usr/local/include/c++/3.3.1/bits/basic_ios.h:44,
                  from /usr/local/include/c++/3.3.1/ios:51,
                  from /usr/local/include/c++/3.3.1/istream:44,
                  from /usr/local/include/c++/3.3.1/fstream:45,
                  from fstream.cpp:1:
/usr/local/include/c++/3.3.1/i686-pc-cygwin/bits/ctype_base.h:46: error: 
`_U'
    was not declared in this scope
(similar errors follow; messages elided for brevity.)
 >$ ls
 >a.exe*  fstream.cpp
 >$ ./a
 >$ cygcheck a
 >Found: .\a.exe
 >a.exe
 >  C:\WINNT\System32\msvcrt.dll
 >    C:\WINNT\System32\KERNEL32.dll
 >      C:\WINNT\System32\ntdll.dll
 >
 >Can you run it with gdb and try to figure out what fails for you?

I've never used gdb, but here goes... install... try it...

For some reason I couldn't get a meaningful stack trace, but by stepping it 
was easy to isolate the problem. It is in the execution of the call:

    is.rdbuf()->in_avail()

is.rdbuf() looks like it is returning the correct pointer, but in_avail() 
is dying. If I replace the call with a constant, say 16000, the program 
runs
fine.

Does that help?

By the way, the above results hold regardless of whether the program is run 
from the Win XP command line or the bash command line.

--Beman

--
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple
Problem reports:       http://cygwin.com/problems.html
Documentation:         http://cygwin.com/docs.html
FAQ:                   http://cygwin.com/faq/