This is the mail archive of the cygwin mailing list for the Cygwin project.

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: problem with i686-w64-mingw32-gcc -fstack-protector-all

Lee wrote:

+ ./ssp.exe testtestx
./doit: line 11:  9128 Illegal instruction     ./ssp.exe testtestx
+ echo -e '\n\n'

The *** stack smashing detected *** message from MinGW runtime is only
visible if stdio is attached to a Windows console.
But even after re-reading &  I'm still missing why _no_
output is displayed before the 'Illegal instruction' output line.

Stdio streams are usually full buffered if not attached to a tty/console. Buffers are flushed on regular exit(), but not on abnormal termination. Add fflush() calls to fix.

Works for me if one more overflow char is added:

Cygwin mintty:

$ ./ssp testtestx
main: argv[1]=testtestx
doit: s="testtestx"   buf="12345678"  i=1
doit: s="testtestx"   buf="testtestx"  i=1
main: exit
Interesting.  I have Windows 10 & i686-w64-mingw32-gcc (GCC) 6.3.0   you?

Same (Win10.0.15063 x64 German).


Anyway.. Thank you!!  It's been driving me nuts trying to figure out
why all I get is 'Illegal instruction'

The 'Illegal instruction' is printed by the Cygwin shell because the program fails with STATUS_ILLEGAL_INSTRUCTION which is mapped to SIGILL.

The libspp code[1] shows that the program is terminated with __builtin_trap(). GCC then generates the x86 instruction UD2 ("defined" as "undefined instruction" :-) In the MinGW case, stack error messages are written to CONOUT$ or are not written if no console is attached (Cygwin and others: /dev/tty or syslog()).



Problem reports:
Unsubscribe info:

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]