I tried your example program because I've got problems with my TCM-port, which requires g++-2.95 to compile. I'm afraid I can't reproduce your SEGFAULT, it seems to work with both compiler versions on my installation.
BTW: if someone's got a little time, I could use some help with TCM. As I wrote yesterday, TCM crashes when compiled on cygwin 1.5.5. I recompiled TCM with "-g" and ran gdb on it, but got no useful output:
Program received signal SIGSEGV, Segmentation fault. 0x1f9357f0 in ?? ()
When breakpointing on main() and singlestepping, the crash occurs after 2 or three steps in a comment (?) of a header-file. I guess I'm doing something wrong ...
As I said: any hints are welcome!
Regards, Daniel
William A. Hoffman wrote:
The following program crashes when compiled with g++-2:
---------start cyggcc295bug.cxx------- #include <fstream>
int main() { char buffer[1024]; std::ifstream fin("./cyggcc295bug.cxx"); if(fin) { fin.getline(buffer, 10); // Running a.exe crashes here. return 0; } return 1; } ---------end cyggcc295bug.cxx-------
If you save the above program into g++-2 cyggcc295bug.cxx
Then try this: g++-2 cyggcc295bug.cxx ./a.exe (seg fault)
g++ cyggcc295bug.cxx ./a.exe (works)
It works when compiled with g++ (which is g++ 3.3.1)
There seem to be several reports of this bug : http://www.cygwin.com/ml/cygwin/2003-09/msg01533.html http://www.cygwin.com/ml/cygwin/2003-09/msg01831.html http://www.cygwin.com/ml/cygwin/2003-09/msg00994.html
However, it has been suggested that the posters use the newer g++ (3.3). I acknowledge that it works with the 3.3.1 compiler. However, there are reasons to use gcc 2.95 based compilers.
Here is the output of cygcheck -svr:
Cygwin Win95/NT Configuration Diagnostics Current System Time: Fri Oct 03 11:01:02 2003
Windows XP Professional Ver 5.1 Build 2600 Service Pack 1
Path: C:\cygwin\usr\local\bin C:\cygwin\bin C:\cygwin\bin C:\cygwin\usr\sbin C:\cygwin\sbin c:\WINDOWS\system32 c:\WINDOWS c:\WINDOWS\System32\Wbem c:\Program Files\Common Files\Adaptec Shared\System
Output from C:\cygwin\bin\id.exe (nontsec) UID: 11140(kingb) GID: 513(None) 513(None)
Output from C:\cygwin\bin\id.exe (ntsec) UID: 11140(kingb) GID: 513(None) 547(Power Users) 545(Users) 10545(mkgroup_l_d)
SysDir: C:\WINDOWS\System32 WinDir: C:\WINDOWS
CYGWIN = `ntsec tty' HOME = `C:\cygwin\home\kingb' MAKE_MODE = `unix' PWD = `/c/Brad/Programs/CMake-gcc-2' USER = `kingb'
ALLUSERSPROFILE = `C:\Documents and Settings\All Users' APPDATA = `C:\Documents and Settings\kingb\Application Data' BLOCKER_FOR_ZPROFILE = `1' BLOCKER_FOR_ZSHENV = `1' BOOST_ROOT = `c:/Brad/Programs/Boost' CC = `gcc-2' CFLAGS = `-g -Wall -W' COLORFGBG = `15;default;0' COLORTERM = `rxvt-xpm' COMMONPROGRAMFILES = `C:\Program Files\Common Files' COMPUTERNAME = `MOONGLOW' COMSPEC = `C:\WINDOWS\system32\cmd.exe' CVS_RSH = `ssh' CXX = `g++-2' CXXFLAGS = `-g -Wall -W -Woverloaded-virtual -Wunused' DISPLAY = `:0' HISTFILE = `/home/kingb/.zsh_history' HISTSIZE = `10000' HOMEDRIVE = `C:' HOMEPATH = `\Documents and Settings\kingb' INCLUDE = `C:\Program Files\Microsoft Visual Studio .NET 2003\SDK\v1.1\include\;C:\Program Files\Microsoft Visual Studio .NET\FrameworkSDK\include\' LESS = `--LONG-PROMPT --chop-long-lines --ignore-case' LESSCHARSET = `latin1' LIB = `C:\Program Files\Microsoft Visual Studio .NET 2003\SDK\v1.1\Lib\;C:\Program Files\Microsoft Visual Studio .NET\FrameworkSDK\Lib\' LOGNAME = `KINGB' LOGONSERVER = `\\TRIPOINT' LS_OPTIONS = `--literal --file-type --color=auto --tabsize=0' MANPATH = `:/usr/ssl/man' MANWIDTH = `80' NUMBER_OF_PROCESSORS = `1' OLDPWD = `/c/Brad/Programs' OS = `Windows_NT' PARAVIEW_SETUP_SCRIPT = `. ~/Setup/paraview_env.sh' PATHEXT = `.COM;.EXE;.BAT;.CMD;.VBS;.VBE;.JS;.JSE;.WSF;.WSH;.tcl' PROCESSOR_ARCHITECTURE = `x86' PROCESSOR_IDENTIFIER = `x86 Family 15 Model 2 Stepping 4, GenuineIntel' PROCESSOR_LEVEL = `15' PROCESSOR_REVISION = `0204' PROGRAMFILES = `C:\Program Files' PS1 = `([EMAIL PROTECTED])[%h] %~ %% ' PYTHON_ROOT = `c:/Python22' PYTHON_VERSION = `2.2' SAVEHIST = `10000' SESSIONNAME = `Console' SHELL = `/bin/zsh' SHLVL = `1' SYSTEMDRIVE = `C:' SYSTEMROOT = `C:\WINDOWS' TEMP = `c:\DOCUME~1\kingb\LOCALS~1\Temp' TERM = `xterm' TMP = `c:\DOCUME~1\kingb\LOCALS~1\Temp' TZ = `EST5EST4,M4.1.0/2,M10.5.0/2' USERDNSDOMAIN = `KITWAREIN.COM' USERDOMAIN = `KITWAREIN' USERNAME = `KINGB' USERPROFILE = `C:\Documents and Settings\kingb' VS71COMNTOOLS = `C:\Program Files\Microsoft Visual Studio .NET 2003\Common7\Tools\' VSCOMNTOOLS = `"C:\Program Files\Microsoft Visual Studio .NET\Common7\Tools\"' WINDIR = `C:\WINDOWS' WINDOWID = `168048080' WINDOWMANAGER = `blackbox' _ = `/usr/bin/cygcheck'
HKEY_CURRENT_USER\Software\Cygnus Solutions HKEY_CURRENT_USER\Software\Cygnus Solutions\Cygwin HKEY_CURRENT_USER\Software\Cygnus Solutions\Cygwin\mounts v2 HKEY_CURRENT_USER\Software\Cygnus Solutions\Cygwin\Program Options HKEY_LOCAL_MACHINE\SOFTWARE\Cygnus Solutions HKEY_LOCAL_MACHINE\SOFTWARE\Cygnus Solutions\Cygwin HKEY_LOCAL_MACHINE\SOFTWARE\Cygnus Solutions\Cygwin\mounts v2 (default) = `/cygdrive' cygdrive flags = 0x00000020 HKEY_LOCAL_MACHINE\SOFTWARE\Cygnus Solutions\Cygwin\mounts v2\/ (default) = `C:\cygwin' flags = 0x00000008 HKEY_LOCAL_MACHINE\SOFTWARE\Cygnus Solutions\Cygwin\mounts v2\/usr/bin (default) = `C:\cygwin/bin' flags = 0x00000008 HKEY_LOCAL_MACHINE\SOFTWARE\Cygnus Solutions\Cygwin\mounts v2\/usr/lib (default) = `C:\cygwin/lib' flags = 0x00000008 HKEY_LOCAL_MACHINE\SOFTWARE\Cygnus Solutions\Cygwin\Program Options
c: hd NTFS 57192Mb 87% CP CS UN PA FC d: cd CDFS 544Mb 100% CS DN600ENU2 e: cd N/A N/A
C:\cygwin / system textmode C:\cygwin/bin /usr/bin system textmode C:\cygwin/lib /usr/lib system textmode . /cygdrive system textmode,cygdrive
Found: C:\cygwin\bin\awk.exe Found: C:\cygwin\bin\bash.exe Found: C:\cygwin\bin\cat.exe Found: C:\cygwin\bin\cp.exe Found: C:\cygwin\bin\cpp.exe Found: C:\cygwin\bin\find.exe Found: C:\cygwin\bin\gcc.exe Found: C:\cygwin\bin\gdb.exe Found: C:\cygwin\bin\grep.exe Found: C:\cygwin\bin\ld.exe Found: C:\cygwin\bin\ls.exe Found: C:\cygwin\bin\make.exe Found: C:\cygwin\bin\mv.exe Found: C:\cygwin\bin\rm.exe Found: C:\cygwin\bin\sed.exe Found: C:\cygwin\bin\sh.exe Found: C:\cygwin\bin\tar.exe
61k 2003/08/09 C:\cygwin\bin\cygbz2-1.dll - os=4.0 img=1.0 sys=4.0 "cygbz2-1.dll" v0.0 ts=2003/8/9 2:35 842k 2003/09/30 C:\cygwin\bin\cygcrypto-0.9.7.dll - os=4.0 img=1.0 sys=4.0 "cygcrypto-0.9.7.dll" v0.0 ts=2003/9/30 12:49 645k 2003/04/11 C:\cygwin\bin\cygcrypto.dll - os=4.0 img=1.0 sys=4.0 "cygcrypto.dll" v0.0 ts=2003/4/11 6:37 380k 2002/07/24 C:\cygwin\bin\cygdb-3.1.dll - os=4.0 img=1.0 sys=4.0 "cygdb-3.1.dll" v0.0 ts=2002/7/24 12:24 487k 2002/07/24 C:\cygwin\bin\cygdb_cxx-3.1.dll - os=4.0 img=1.0 sys=4.0 "cygdb_cxx-3.1.dll" v0.0 ts=2002/7/24 12:25 132k 2003/07/12 C:\cygwin\bin\cygexpat-0.dll - os=4.0 img=1.0 sys=4.0 "cygexpat-0.dll" v0.0 ts=2003/7/12 7:33 45k 2001/04/25 C:\cygwin\bin\cygform5.dll - os=4.0 img=1.0 sys=4.0 "cygform5.dll" v0.0 ts=2001/4/25 1:28 35k 2002/01/09 C:\cygwin\bin\cygform6.dll - os=4.0 img=1.0 sys=4.0 "cygform6.dll" v0.0 ts=2002/1/9 1:03 48k 2003/08/09 C:\cygwin\bin\cygform7.dll - os=4.0 img=1.0 sys=4.0 "cygform7.dll" v0.0 ts=2003/8/9 5:25 28k 2003/07/20 C:\cygwin\bin\cyggdbm-3.dll - os=4.0 img=1.0 sys=4.0 "cyggdbm-3.dll" v0.0 ts=2003/7/20 3:58 30k 2003/08/11 C:\cygwin\bin\cyggdbm-4.dll - os=4.0 img=1.0 sys=4.0 "cyggdbm-4.dll" v0.0 ts=2003/8/10 22:12 19k 2003/03/22 C:\cygwin\bin\cyggdbm.dll - os=4.0 img=1.0 sys=4.0 "cyggdbm.dll" v0.0 ts=2002/2/19 22:05 15k 2003/07/20 C:\cygwin\bin\cyggdbm_compat-3.dll - os=4.0 img=1.0 sys=4.0 "cyggdbm_compat-3.dll" v0.0 ts=2003/7/20 4:00 15k 2003/08/11 C:\cygwin\bin\cyggdbm_compat-4.dll - os=4.0 img=1.0 sys=4.0 "cyggdbm_compat-4.dll" v0.0 ts=2003/8/10 22:13 69k 2003/08/10 C:\cygwin\bin\cyggettextlib-0-12-1.dll - os=4.0 img=1.0 sys=4.0 "cyggettextlib-0-12-1.dll" v0.0 ts=2003/8/10 18:10 12k 2003/08/10 C:\cygwin\bin\cyggettextpo-0.dll - os=4.0 img=1.0 sys=4.0 "cyggettextpo-0.dll" v0.0 ts=2003/8/10 18:11 134k 2003/08/10 C:\cygwin\bin\cyggettextsrc-0-12-1.dll - os=4.0 img=1.0 sys=4.0 "cyggettextsrc-0-12-1.dll" v0.0 ts=2003/8/10 18:10 17k 2001/06/28 C:\cygwin\bin\cyghistory4.dll - os=4.0 img=1.0 sys=4.0 "cyghistory4.dll" v0.0 ts=2001/1/6 23:34 29k 2003/08/10 C:\cygwin\bin\cyghistory5.dll - os=4.0 img=1.0 sys=4.0 "cyghistory5.dll" v0.0 ts=2003/8/10 19:16 958k 2003/08/10 C:\cygwin\bin\cygiconv-2.dll - os=4.0 img=1.0 sys=4.0 "cygiconv-2.dll" v0.0 ts=2003/8/10 16:57 22k 2001/12/13 C:\cygwin\bin\cygintl-1.dll - os=4.0 img=1.0 sys=4.0 "cygintl-1.dll" v0.0 ts=2001/12/13 4:28 37k 2003/08/10 C:\cygwin\bin\cygintl-2.dll - os=4.0 img=1.0 sys=4.0 "cygintl-2.dll" v0.0 ts=2003/8/10 17:50 26k 2001/04/25 C:\cygwin\bin\cygmenu5.dll - os=4.0 img=1.0 sys=4.0 "cygmenu5.dll" v0.0 ts=2001/4/25 1:27 20k 2002/01/09 C:\cygwin\bin\cygmenu6.dll - os=4.0 img=1.0 sys=4.0 "cygmenu6.dll" v0.0 ts=2002/1/9 1:03 29k 2003/08/09 C:\cygwin\bin\cygmenu7.dll - os=4.0 img=1.0 sys=4.0 "cygmenu7.dll" v0.0 ts=2003/8/9 5:25 156k 2001/04/25 C:\cygwin\bin\cygncurses++5.dll - os=4.0 img=1.0 sys=4.0 "cygncurses++5.dll" v0.0 ts=2001/4/25 1:29 175k 2002/01/09 C:\cygwin\bin\cygncurses++6.dll - os=4.0 img=1.0 sys=4.0 "cygncurses++6.dll" v0.0 ts=2002/1/9 1:03 226k 2001/04/25 C:\cygwin\bin\cygncurses5.dll - os=4.0 img=1.0 sys=4.0 "cygncurses5.dll" v0.0 ts=2001/4/25 1:17 202k 2002/01/09 C:\cygwin\bin\cygncurses6.dll - os=4.0 img=1.0 sys=4.0 "cygncurses6.dll" v0.0 ts=2002/1/9 1:03 224k 2003/08/09 C:\cygwin\bin\cygncurses7.dll - os=4.0 img=1.0 sys=4.0 "cygncurses7.dll" v0.0 ts=2003/8/9 5:24 15k 2001/04/25 C:\cygwin\bin\cygpanel5.dll - os=4.0 img=1.0 sys=4.0 "cygpanel5.dll" v0.0 ts=2001/4/25 1:27 12k 2002/01/09 C:\cygwin\bin\cygpanel6.dll - os=4.0 img=1.0 sys=4.0 "cygpanel6.dll" v0.0 ts=2002/1/9 1:03 19k 2003/08/09 C:\cygwin\bin\cygpanel7.dll - os=4.0 img=1.0 sys=4.0 "cygpanel7.dll" v0.0 ts=2003/8/9 5:24 67k 2003/09/10 C:\cygwin\bin\cygpcre-0.dll - os=4.0 img=1.0 sys=4.0 "cygpcre-0.dll" v0.0 ts=2003/9/10 10:25 63k 2003/04/11 C:\cygwin\bin\cygpcre.dll - os=4.0 img=1.0 sys=4.0 "cygpcre.dll" v0.0 ts=2003/4/11 4:31 15k 2003/09/10 C:\cygwin\bin\cygpcreposix-0.dll - os=4.0 img=1.0 sys=4.0 "cygpcreposix-0.dll" v0.0 ts=2003/9/10 10:25 61k 2003/04/11 C:\cygwin\bin\cygpcreposix.dll - os=4.0 img=1.0 sys=4.0 "cygpcreposix.dll" v0.0 ts=2003/4/11 4:31 1100k 2003/08/29 C:\cygwin\bin\cygperl5_8_0.dll - os=4.0 img=1.0 sys=4.0 "cygperl5_8_0.dll" v0.0 ts=2003/8/29 6:20 22k 2002/06/09 C:\cygwin\bin\cygpopt-0.dll - os=4.0 img=1.0 sys=4.0 "cygpopt-0.dll" v0.0 ts=2002/6/9 1:45 108k 2001/06/28 C:\cygwin\bin\cygreadline4.dll - os=4.0 img=1.0 sys=4.0 "cygreadline4.dll" v0.0 ts=2001/1/6 23:34 148k 2003/08/10 C:\cygwin\bin\cygreadline5.dll - os=4.0 img=1.0 sys=4.0 "cygreadline5.dll" v0.0 ts=2003/8/10 19:16 171k 2003/09/30 C:\cygwin\bin\cygssl-0.9.7.dll - os=4.0 img=1.0 sys=4.0 "cygssl-0.9.7.dll" v0.0 ts=2003/9/30 12:49 165k 2003/04/11 C:\cygwin\bin\cygssl.dll - os=4.0 img=1.0 sys=4.0 "cygssl.dll" v0.0 ts=2003/4/11 6:37 60k 2003/08/09 C:\cygwin\bin\cygz.dll - os=4.0 img=1.0 sys=4.0 "cygz.dll" v0.0 ts=2003/8/9 2:28 949k 2003/09/20 C:\cygwin\bin\cygwin1.dll - os=4.0 img=1.0 sys=4.0 "cygwin1.dll" v0.0 ts=2003/9/20 16:31 Cygwin DLL version info: DLL version: 1.5.5 DLL epoch: 19 DLL bad signal mask: 19005 DLL old termios: 5 DLL malloc env: 28 API major: 0 API minor: 94 Shared data: 3 DLL identifier: cygwin1 Mount registry: 2 Cygnus registry name: Cygnus Solutions Cygwin registry name: Cygwin Program options name: Program Options Cygwin mount registry name: mounts v2 Cygdrive flags: cygdrive flags Cygdrive prefix: cygdrive prefix Cygdrive default prefix: Build date: Sat Sep 20 16:31:15 EDT 2003 CVS tag: cr-0x9b Shared id: cygwin1S3
Cygwin Package Information Last downloaded files to: C:\Brad\Installs\Cygwin Last downloaded files from: ftp://archive.progeny.com/cygwin
Package Version _update-info-dir 00221-1 ash 20020731-3 autoconf 2.57a-1 autoconf-devel 2.57-2 autoconf-stable 2.13-5 automake 1.7.5a-1 automake-devel 1.7.6-2 automake-stable 1.4p5-6 base-files 2.6-1 base-passwd 1.1-1 bash 2.05b-15 binutils 20030901-1 bison 20030307-1 bzip2 1.0.2-5 clear 1.0-1 cpio 2.5-3 crypt 1.0-2 cvs 1.11.6-3 cygrunsrv 0.96-2 cygutils 1.2.1-2 cygwin 1.5.5-1 cygwin-doc 1.3-6 diffutils 2.8.4-1 editrights 1.01-1 expat 1.95.6-2 file 4.03-2 fileutils 4.1-2 findutils 4.1.7-4 flex 2.5.4a-3 gawk 3.1.3-3 gcc 3.3.1-2 gcc-mingw 20030911-3 gcc2 2.95.3-10 gdb 20030919-1 gdbm 1.8.3-7 grep 2.5-1 groff 1.18.1-2 gzip 1.3.5-1 inetutils 1.3.2-25 less 381-1 libbz2_1 1.0.2-5 libdb3.1 3.1.17-2 libgdbm 1.8.0-5 libgdbm-devel 1.8.3-7 libgdbm3 1.8.3-3 libgdbm4 1.8.3-7 libgettextpo0 0.12.1-3 libiconv2 1.9.1-3 libintl1 0.10.40-1 libintl2 0.12.1-3 libncurses5 5.2-1 libncurses6 5.2-8 libncurses7 5.3-4 libpcre 4.1-1 libpcre0 4.4-2 libpopt0 1.6.4-4 libreadline4 4.1-2 libreadline5 4.3-5 login 1.9-7 m4 1.4-1 make 3.80-1 man 1.5j-2 mingw-runtime 3.1-1 mktemp 1.5-3 ncurses 5.3-4 opengl 1.1.0-6 openssh 3.7.1p2-1 openssl 0.9.7c-1 openssl096 0.9.6j-1 patch 2.5.8-8 perl 5.8.0-5 python 2.3-2 readline 4.3-5 rxvt 2.7.10-3 sed 4.0.7-3 sh-utils 2.0.15-4 tar 1.13.25-3 tcltk 20030901-1 termcap 20021106-2 terminfo 5.3_20030726-1 texinfo 4.2-4 textutils 2.0.21-1 vim 6.2.098-1 w32api 2.4-1 wget 1.8.2-2 which 1.5-2 zip 2.3-5 zlib 1.1.4-4 zsh 4.0.7-2 Use -h to see help about each section