Web lists-archives.com

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.
Yes!
But even after re-reading https://github.com/mintty/mintty/wiki/Tips &
https://github.com/mintty/mintty/issues/56  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()).

Christian

[1]
https://gcc.gnu.org/viewcvs/gcc/trunk/libssp/ssp.c?revision=233253&view=markup


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