public inbox for cygwin@cygwin.com
 help / color / mirror / Atom feed
From: Christian Franke <Christian.Franke@t-online.de>
To: cygwin@cygwin.com
Subject: Re: problem with i686-w64-mingw32-gcc -fstack-protector-all
Date: Sun, 08 Oct 2017 12:59:00 -0000	[thread overview]
Message-ID: <7a27bdaa-b3ad-1d33-5206-f32fabeb10c1@t-online.de> (raw)
In-Reply-To: <CAD8GWsu1CetVFeJPz4zxhZfDShQBQrHanzuyfuFu16VV=XxgDQ@mail.gmail.com>

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

      reply	other threads:[~2017-10-08 12:59 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-10-03 18:26 Lee
2017-10-04 19:18 ` Christian Franke
2017-10-05  5:41   ` Lee
2017-10-08 12:59     ` Christian Franke [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=7a27bdaa-b3ad-1d33-5206-f32fabeb10c1@t-online.de \
    --to=christian.franke@t-online.de \
    --cc=cygwin@cygwin.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).