gcc version 2.95.3-5: assert() does not work as expected

Torrisi Fabio torrisi@aut.ee.ethz.ch
Wed Jan 9 03:20:00 GMT 2002


Dear maintainers,

Please consider the following bug:

Problem:
assert does not work as written in the manual

symptom:
If I register a signal handler for SIGABRT it does not get called by assert

As the man pages claim:
assert(3)
        When expression evaluates to false  (zero),  assert  calls
        abort,  after first printing a message showing what failed
        and where:
and
abort(3)
        Before  terminating  your program, abort raises the excep-
        tion SIGABRT (using ` raise(SIGABRT)').  If you have  used
        signal  to  register  an exception handler for this condi-
        tion, that handler has the opportunity to retain  control,
        thereby avoiding program termination.

therefore assert should go trough the signal handler if it evaluated FALSE.

This indeed happens in Unix and in linux

The problem can be reproduced compiling the enclosed main.cc file

The problem was experimented under windows 98 running
gcc version 2.95.3-5 (cygwin special) (more details in the enclosed 
cygcheck.out
file)

Regards,
	Fabio Torrisi
-------------- next part --------------
#include <stdio.h>
#include <fstream.h>
#include <signal.h>
#include <string>




/**
  *	Handle a big failure: segmentation fault or abort signal by simply
  *	printing out the email address to complain with
  */
void failure_handler(int sig) {
	string error;
	if (sig == SIGSEGV) error = "Segmentation fault";
		else if (sig == SIGABRT) error = "Abort signal";
			else error = "Unknown";
	cerr << "The program crashed due to some internal error (" << error << ")\n";
	cerr << "Please report the error message to maintainer@mantain \n";
	exit(1);
}


/****************************************************************************** 
 * Main function
 ******************************************************************************/
int 
main(void) 
{
	// register the internal error handelrs
	signal(SIGABRT, &failure_handler);
	signal(SIGSEGV, &failure_handler);
	// try out
	assert(0);
	return 0;
}
-------------- next part --------------

Cygnus Win95/NT Configuration Diagnostics
Current System Time: Wed Jan 09 12:14:02 2002

Windows 98 SE Ver 4.10 Build 2222 

Path:	C:\usr\cygwin\usr\local\bin
	C:\usr\cygwin\bin
	C:\usr\cygwin\bin
	c:\WINDOWS
	c:\windows
	c:\windows\COMMAND
	c:\USR\BIN
	c:\USR\PERL\BIN
	c:\USR\MATLABR11\BIN
	c:\USR\TEXMF\MIKTEX\BIN
	c:\USR\ALADDIN\GS6.01\BIN
	c:\USR\IMAGEMAGICK
	c:\USR\ILOG\CPLEX70\BIN\MSVC6\STAT_MDA
	c:\USR\NAG5\DLL
	c:\USR\TCL\BIN

SysDir: C:\WINDOWS\SYSTEM
WinDir: C:\WINDOWS

HOME = `d:\home\torrisi'
MAKE_MODE = `unix'
PWD = `/home/torrisi/windesktop/test'
USER = `torrisi'

BLASTER = `A220 I5 D1 T4 P330'
CMDLINE = `rxvt -fn "-*-Courier-medium-r-*-13-*" -geometry 80x26+10+330 -sl 5000 -e /usr/bin/bash --login -i'
COLORFGBG = `0;default;15'
COLORTERM = `rxvt-xpm'
COMSPEC = `C:\WINDOWS\COMMAND.COM'
DISPLAY = `:0'
OLDPWD = `/home/torrisi'
PROMPT = `$p$g'
PS1 = `\[\033]0;\w\007
\033[32m\]\u@\h \[\033[33m\w\033[0m\]
$ '
SHLVL = `1'
TEMP = `c:\windows\temp'
TERM = `xterm'
WINBOOTDIR = `C:\WINDOWS'
WINDIR = `C:\WINDOWS'
WINDOWID = `72945808'
_ = `/usr/bin/cygcheck'

HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\MenuOrder\Start Menu\&Programs\Development\Cygnus Solutions
  (default) = (unsupported type)
HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\MenuOrder\Start Menu\&Programs\Development\Languages\Cygnus Solutions
  (default) = (unsupported type)
HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\MenuOrder\Start Menu\&Programs\Cygnus Solutions
  (default) = (unsupported type)
HKEY_CURRENT_USER\Software\Cygnus Solutions
HKEY_CURRENT_USER\Software\Cygnus Solutions\Cygwin
HKEY_CURRENT_USER\Software\Cygnus Solutions\Cygwin\mounts v2
  (default) = `/cygdrive'
  cygdrive flags = 0x00000022
HKEY_CURRENT_USER\Software\Cygnus Solutions\Cygwin\mounts v2\/home
  (default) = `d:\home'
  flags = 0x00000000
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
HKEY_LOCAL_MACHINE\Software\Cygnus Solutions\Cygwin\mounts v2\/
  (default) = `C:/usr/cygwin'
  flags = 0x0000000a
HKEY_LOCAL_MACHINE\Software\Cygnus Solutions\Cygwin\mounts v2\/usr/bin
  (default) = `C:/usr/cygwin/bin'
  flags = 0x0000000a
HKEY_LOCAL_MACHINE\Software\Cygnus Solutions\Cygwin\mounts v2\/usr/lib
  (default) = `C:/usr/cygwin/lib'
  flags = 0x0000000a
HKEY_LOCAL_MACHINE\Software\Cygnus Solutions\Cygwin\Program Options

a:  fd           N/A    N/A                    
c:  hd  FAT32   8181Mb  62% CP    UN           
d:  hd  FAT32   3303Mb  49% CP    UN           
f:  cd  CDFS     179Mb 100%       UN           Data
s:  fd           N/A    N/A                    

d:\home            /home      user    textmode
.                  /cygdrive  user    binmode,noumount
C:/usr/cygwin      /          system  binmode
C:/usr/cygwin/bin  /usr/bin   system  binmode
C:/usr/cygwin/lib  /usr/lib   system  binmode

Found: C:\usr\cygwin\bin\bash.exe
Found: C:\usr\cygwin\bin\cat.exe
Found: C:\usr\cygwin\bin\cpp.exe
Found: C:\usr\cygwin\bin\find.exe
Found: c:\windows\COMMAND\find.exe
Warning: C:\usr\cygwin\bin\find.exe hides c:\windows\COMMAND\find.exe
Found: C:\usr\cygwin\bin\gcc.exe
Found: C:\usr\cygwin\bin\gdb.exe
Found: C:\usr\cygwin\bin\ld.exe
Found: C:\usr\cygwin\bin\ls.exe
Found: C:\usr\cygwin\bin\make.exe
Found: C:\usr\cygwin\bin\sh.exe

   81k 2001/10/20 C:\usr\cygwin\bin\cygitcl30.dll - os=4.0 img=1.0 sys=4.0
                  "cygitcl30.dll" v0.0 ts=2001/10/20 2:25
   35k 2001/10/20 C:\usr\cygwin\bin\cygitk30.dll - os=4.0 img=1.0 sys=4.0
                  "cygitk30.dll" v0.0 ts=2001/10/20 2:25
  390k 2001/10/20 C:\usr\cygwin\bin\cygtcl80.dll - os=4.0 img=1.0 sys=4.0
                  "cygtcl80.dll" v0.0 ts=2001/10/20 2:24
    5k 2001/10/20 C:\usr\cygwin\bin\cygtclpip80.dll - os=4.0 img=1.0 sys=4.0
   10k 2001/10/20 C:\usr\cygwin\bin\cygtclreg80.dll - os=4.0 img=1.0 sys=4.0
                  "cygtclreg80.dll" v0.0 ts=2001/10/20 2:24
  623k 2001/10/20 C:\usr\cygwin\bin\cygtk80.dll - os=4.0 img=1.0 sys=4.0
                  "cygtk80.dll" v0.0 ts=2001/10/20 2:25
   18k 2000/10/23 C:\usr\cygwin\bin\cyggdbm.dll - os=4.0 img=1.0 sys=4.0
                  "cyggdbm.dll" v0.0 ts=2000/10/23 4:26
  163k 2001/05/06 C:\usr\cygwin\bin\cygpng2.dll - os=4.0 img=1.0 sys=4.0
                  "cygpng2.dll" v0.0 ts=2001/5/6 6:05
   45k 2001/07/04 C:\usr\cygwin\bin\cygjbig1.dll - os=4.0 img=1.0 sys=4.0
                  "cygjbig1.dll" v0.0 ts=2001/7/4 5:25
  119k 2001/06/06 C:\usr\cygwin\bin\cygjpeg6b.dll - os=4.0 img=1.0 sys=4.0
                  "cygjpeg6b.dll" v0.0 ts=2001/6/6 6:27
  821k 2001/11/19 C:\usr\cygwin\bin\cygcrypto.dll - os=4.0 img=1.0 sys=4.0
                  "cygcrypto.dll" v0.0 ts=2001/11/20 0:42
  231k 2001/11/19 C:\usr\cygwin\bin\cygssl.dll - os=4.0 img=1.0 sys=4.0
                  "cygssl.dll" v0.0 ts=2001/11/20 0:42
   17k 2001/06/28 C:\usr\cygwin\bin\cyghistory4.dll - os=4.0 img=1.0 sys=4.0
                  "cyghistory4.dll" v0.0 ts=2001/1/7 5:34
   21k 2001/06/28 C:\usr\cygwin\bin\cyghistory5.dll - os=4.0 img=1.0 sys=4.0
                  "cyghistory5.dll" v0.0 ts=2001/6/28 4:27
  108k 2001/06/28 C:\usr\cygwin\bin\cygreadline4.dll - os=4.0 img=1.0 sys=4.0
                  "cygreadline4.dll" v0.0 ts=2001/1/7 5:34
  135k 2001/06/28 C:\usr\cygwin\bin\cygreadline5.dll - os=4.0 img=1.0 sys=4.0
                  "cygreadline5.dll" v0.0 ts=2001/6/28 4:27
  245k 2001/06/12 C:\usr\cygwin\bin\cygtiff3.dll - os=4.0 img=1.0 sys=4.0
                  "cygtiff3.dll" v0.0 ts=2001/6/12 19:25
   41k 2001/07/04 C:\usr\cygwin\bin\cygXpm-noX4.dll - os=4.0 img=1.0 sys=4.0
                  "cygXpm-noX4.dll" v0.0 ts=2001/7/4 3:21
   45k 2001/07/04 C:\usr\cygwin\bin\cygXpm-X4.dll - os=4.0 img=1.0 sys=4.0
                  "cygXpm-X4.dll" v0.0 ts=2000/11/20 3:45
   49k 2001/02/03 C:\usr\cygwin\bin\cygz.dll - os=4.0 img=1.0 sys=4.0
                  "cygz.dll" v0.0 ts=2001/2/3 21:35
   56k 2000/12/03 C:\usr\cygwin\bin\cygbz21.0.dll - os=4.0 img=1.0 sys=4.0
                  "cygbz21.0.dll" v0.0 ts=2000/11/21 0:53
   40k 2001/11/21 C:\usr\cygwin\bin\cygpcre.dll - os=4.0 img=1.0 sys=4.0
                  "cygpcre.dll" v0.0 ts=2001/11/21 23:15
  102k 2001/12/06 C:\usr\cygwin\bin\cygcurl-2.dll - os=4.0 img=1.0 sys=4.0
                  "cygcurl-2.dll" v0.0 ts=2001/12/6 19:45
   34k 2001/09/30 C:\usr\cygwin\bin\cygform6.dll - os=4.0 img=1.0 sys=4.0
                  "cygform6.dll" v0.0 ts=2001/9/30 4:43
   19k 2001/09/30 C:\usr\cygwin\bin\cygmenu6.dll - os=4.0 img=1.0 sys=4.0
                  "cygmenu6.dll" v0.0 ts=2001/9/30 4:43
  175k 2001/09/30 C:\usr\cygwin\bin\cygncurses++6.dll - os=4.0 img=1.0 sys=4.0
                  "cygncurses++6.dll" v0.0 ts=2001/9/30 4:45
  201k 2001/09/30 C:\usr\cygwin\bin\cygncurses6.dll - os=4.0 img=1.0 sys=4.0
                  "cygncurses6.dll" v0.0 ts=2001/9/30 4:42
   12k 2001/09/30 C:\usr\cygwin\bin\cygpanel6.dll - os=4.0 img=1.0 sys=4.0
                  "cygpanel6.dll" v0.0 ts=2001/9/30 4:43
   21k 2001/06/20 C:\usr\cygwin\bin\cygintl.dll - os=4.0 img=1.0 sys=4.0
                  "cygintl.dll" v0.0 ts=2001/6/20 19:09
   39k 2001/11/21 C:\usr\cygwin\bin\cygpcreposix.dll - os=4.0 img=1.0 sys=4.0
                  "cygpcreposix.dll" v0.0 ts=2001/11/21 23:15
   66k 2001/11/20 C:\usr\cygwin\bin\cygregex.dll - os=4.0 img=1.0 sys=4.0
                  "cygregex.dll" v0.0 ts=2001/11/20 15:44
   22k 2001/12/13 C:\usr\cygwin\bin\cygintl-1.dll - os=4.0 img=1.0 sys=4.0
                  "cygintl-1.dll" v0.0 ts=2001/12/13 10:28
  610k 2001/12/28 C:\usr\cygwin\bin\cygxml2-2.dll - os=4.0 img=1.0 sys=4.0
                  "cygxml2-2.dll" v0.0 ts=2001/12/28 13:49
   73k 2001/12/28 C:\usr\cygwin\bin\cygexslt-0.dll - os=4.0 img=1.0 sys=4.0
                  "cygexslt-0.dll" v0.0 ts=2001/12/28 12:50
  202k 2001/12/28 C:\usr\cygwin\bin\cygxslt-1.dll - os=4.0 img=1.0 sys=4.0
                  "cygxslt-1.dll" v0.0 ts=2001/12/28 12:13
   22k 2001/12/28 C:\usr\cygwin\bin\cygxsltbreakpoint-1.dll - os=4.0 img=1.0 sys=4.0
                  "cygxsltbreakpoint-1.dll" v0.0 ts=2001/12/28 12:50
  720k 2001/12/08 C:\usr\cygwin\bin\cygwin1.dll - os=4.0 img=1.0 sys=4.0
                  "cygwin1.dll" v0.0 ts=2001/12/8 23:02
    Cygwin DLL version info:
        DLL version: 1.3.6
        DLL epoch: 19
        DLL bad signal mask: 19005
        DLL old termios: 5
        DLL malloc env: 28
        API major: 0
        API minor: 47
        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 Dec 8 17:02:30 EST 2001
        CVS tag: cygwin-1-3-6-6
        Shared id: cygwin1S3


Cygwin Package Information
Last downloaded files to: D:\home\torrisi\windesktop\gcc
Last downloaded files from: ftp://sunsite.cnlab-switch.ch/mirror/cygwin

Package             Version             
ash                 20011018-1          
autoconf            2.52a-1             
autoconf-devel      2.52-4              
autoconf-stable     2.13-4              
automake            1.5b-1              
automake-devel      1.5-5               
automake-stable     1.4p5-5             
bash                2.05a-2             
bc                  1.06-1              
binutils            20011002-1          
bison               1.30-1              
byacc               1.9-1               
bzip2               1.0.1-6             
clear               1.0                 
compface            1.4-5               
cpio                2.4.2               
cron                3.0.1-5             
crypt               1.0-1               
ctags               5.2-1               
curl                7.9.2-1             
curl-src            7.9.2-1             
cvs                 1.11.0-1            
cygrunsrv           0.94-2              
cygutils            0.9.7-1             
cygwin              1.3.6-6             
dejagnu             20010117-1          
diff                0.0                 
ed                  0.2-1               
expect              20010117-1          
figlet              2.2-1               
file                3.37-1              
fileutils           4.1-1               
findutils           4.1                 
flex                2.5.4-1             
fortune             1.8-1               
gawk                3.0.4-1             
gcc                 2.95.3-5            
gdb                 20010428-3          
gdbm                1.8.0-3             
gettext             0.10.40-1           
ghostscript         6.51-1              
gperf               0.0                 
grep                2.4.2-1             
groff               1.17.2-1            
gzip                1.3.2-1             
indent              2.2.7-2             
inetutils           1.3.2-17            
irc                 20010101-1          
jbigkit             1.2-4               
jpeg                6b-4                
less                358-3               
libintl             0.10.38-3           
libintl1            0.10.40-1           
libncurses5         5.2-1               
libncurses6         5.2-2               
libpng              1.0.11-1            
libxml2             2.4.12-1            
libxslt             1.0.9-1             
login               1.4-3               
lynx                2.8.4-1             
m4                  0.0                 
make                3.79.1-5            
man                 1.5g-2              
mingw               20010917-1          
mingw-runtime       1.2-1               
mktemp              1.4-1               
mt                  2.0.1-1             
mutt                1.2.5i-6            
nano                1.0.7-1             
ncftp               3.0.2-2             
ncurses             5.2-7               
newlib-man          20001118-1          
opengl              1.1.0-5             
openssh             3.0.2p1-3           
openssl             0.9.6b-2            
patch               2.5-2               
pcre                3.7-1               
perl                5.6.1-2             
popt                1.6.2-1             
postgresql          7.1.3-1             
python              2.2-1               
readline            4.2-3               
regex               4.4-2               
robots              2.0-1               
rsync               2.4.6-3             
rxvt                2.7.2-6             
sed                 3.02-1              
sh-utils            2.0-2               
sharutils           4.2.1-2             
shellutils          0.0                 
shutdown            1.2-2               
squid               2.4-STABLE20010508  
ssmtp               2.38.7-3            
tar                 1.13.19-1           
tcltk               20001125-1          
tcsh                6.11.00-3           
termcap             20010825-1          
terminfo            5.2-1               
tetex-beta          20001218-1          
texinfo             4.0-5               
textutils           2.0.16-1            
tiff                3.5.6beta-2         
time                1.7-1               
units               1.77-1              
unzip               5.41-1              
vim                 6.0.93-1            
w32api              1.2-1               
wget                1.7-1               
which               1.5-1               
xpm                 4.0.0-2             
xpm-nox             4.1.0-1             
zip                 2.3-1               
zlib                1.1.3-6             

Use -h to see help about each section
-------------- next part --------------
---
Fabio D. Torrisi http://www.aut.ee.ethz.ch/~torrisi
-------------- next part --------------
--
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple
Bug reporting:         http://cygwin.com/bugs.html
Documentation:         http://cygwin.com/docs.html
FAQ:                   http://cygwin.com/faq/


More information about the Cygwin mailing list