From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 86006 invoked by alias); 8 Oct 2017 12:59:04 -0000 Mailing-List: contact cygwin-help@cygwin.com; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: cygwin-owner@cygwin.com Mail-Followup-To: cygwin@cygwin.com Received: (qmail 85998 invoked by uid 89); 8 Oct 2017 12:59:04 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-0.6 required=5.0 tests=AWL,BAYES_00,KAM_LAZY_DOMAIN_SECURITY,RCVD_IN_DNSWL_NONE,RP_MATCHES_RCVD autolearn=no version=3.3.2 spammy=German, Tips, driving, H*UA:Firefox X-HELO: mailout03.t-online.de Received: from mailout03.t-online.de (HELO mailout03.t-online.de) (194.25.134.81) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Sun, 08 Oct 2017 12:59:01 +0000 Received: from fwd03.aul.t-online.de (fwd03.aul.t-online.de [172.20.27.148]) by mailout03.t-online.de (Postfix) with SMTP id 4BDB54270781 for ; Sun, 8 Oct 2017 14:58:59 +0200 (CEST) Received: from [192.168.2.101] (XHsxaZZdohwZ-v+3lMYWgN+ehUsCYpyRiU9t+7P1Bq0kb5AAw27K5MjI2IBKRSHw4x@[91.57.244.199]) by fwd03.t-online.de with (TLSv1.2:ECDHE-RSA-AES256-GCM-SHA384 encrypted) esmtp id 1e1BAT-142UEK0; Sun, 8 Oct 2017 14:58:53 +0200 Subject: Re: problem with i686-w64-mingw32-gcc -fstack-protector-all To: cygwin@cygwin.com References: <1d6ce5fb-ea05-b830-8096-98d839cc6e02@t-online.de> From: Christian Franke Message-ID: <7a27bdaa-b3ad-1d33-5206-f32fabeb10c1@t-online.de> Date: Sun, 08 Oct 2017 12:59:00 -0000 User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:53.0) Gecko/20100101 Firefox/53.0 SeaMonkey/2.50 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-IsSubscribed: yes X-SW-Source: 2017-10/txt/msg00075.txt.bz2 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