From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 46076 invoked by alias); 20 Mar 2019 06:34:43 -0000 Mailing-List: contact gcc-help-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Archive: List-Post: List-Help: Sender: gcc-help-owner@gcc.gnu.org Received: (qmail 46067 invoked by uid 89); 20 Mar 2019 06:34:43 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-1.9 required=5.0 tests=BAYES_00,RCVD_IN_DNSWL_NONE autolearn=ham version=3.3.1 spammy= X-HELO: mail-wr1-f48.google.com Received: from mail-wr1-f48.google.com (HELO mail-wr1-f48.google.com) (209.85.221.48) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Wed, 20 Mar 2019 06:34:41 +0000 Received: by mail-wr1-f48.google.com with SMTP id d17so1345362wre.10 for ; Tue, 19 Mar 2019 23:34:41 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=jguk-org.20150623.gappssmtp.com; s=20150623; h=subject:to:references:from:cc:message-id:date:user-agent :mime-version:in-reply-to:content-language:content-transfer-encoding; bh=FfT+spwatGUF4kHebIZHRCUb+nXI9LKDEC/XaZtXi6k=; b=JfGnjQc6ToZXNQYfLfch+CxlYKhkaOf/s3/U/Nlh8jgNFvtk4/Gspiwj37fcOwkgUj kz3/HPFpGNF6fWweTPHWgwuaJTYuBnqWGll2x7fiYuZaz3kgDAiEtKSznulGst7M52bJ 3EQ/ftHD4mPgqTtsLoA8jOjlxkX4oreyrGl94frGrrGk4U2Pxh+y2EmcDexUnydrzKjG 37vyGswzx0eJwXKPrwF5Y+OBJyd/B/PYrCLkqJe6AyuHDcLDsIQFkWo1pstoxoKsxxMs Wi1RYrRU/8mZq24eEtVI3PSe5eWNb2sODzd2QClrjeZckqdpXPInSDzaxiWF2HaYpACC AKow== Return-Path: Received: from [192.168.1.71] (251.98.189.80.dyn.plus.net. [80.189.98.251]) by smtp.gmail.com with ESMTPSA id x17sm2594766wrd.95.2019.03.19.23.34.37 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 19 Mar 2019 23:34:38 -0700 (PDT) Subject: Re: Recursive SIGSEGV question To: Florian Weimer References: <1255ee27-882f-ab4e-ea45-ba6f35791b45@jguk.org> <877ecuikq9.fsf@mid.deneb.enyo.de> From: Jonny Grant Cc: gcc-help Message-ID: Date: Wed, 20 Mar 2019 08:11:00 -0000 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.5.1 MIME-Version: 1.0 In-Reply-To: <877ecuikq9.fsf@mid.deneb.enyo.de> Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit X-SW-Source: 2019-03/txt/msg00121.txt.bz2 On 19/03/2019 22:05, Florian Weimer wrote: > * Jonny Grant: > >> Wanted to ask opinion about the following. >> >> Compiling with g++ 8.2.0 and saw the following. The program was in a >> recursive function call (bug). My test case is attached, although could >> not reproduce exactly same backtrace. >> >> I had a look at https://github.com/lattera/glibc/blob/master/malloc/malloc.c >> >> Is there an issue in _int_malloc? or was it most likely just out of >> memory? Do out of memory issues normally show up as SIGSEGV? I had >> expected some sort of "out of memory" > > This isn't really a GCC question, _int_malloc looks like something > that would be part of glibc. > >> This is the log from own software (not attached) :- >> >> Program terminated with signal SIGSEGV, Segmentation fault. >> #0 0x00007faa0e37b30e in _int_malloc (av=av@entry=0x7fa980000020, >> bytes=bytes@entry=45) at malloc.c:3557 >> 3557 malloc.c: No such file or directory. >> [Current thread is 1 (Thread 0x7fa997860700 (LWP 20571))] >> (gdb) bt >> #0 0x00007faa0e37b30e in _int_malloc (av=av@entry=0x7fa980000020, >> bytes=bytes@entry=45) at malloc.c:3557 >> #1 0x00007faa0e37e2ed in __GI___libc_malloc (bytes=45) at malloc.c:3065 >> #2 0x00007faa0eba21a8 in operator new(unsigned long) () >> from /usr/lib/x86_64-linux-gnu/libstdc++.so.6 > > How does hit go on after that? Where does the fault actually happen? > > See: > > (gdb) print $_siginfo._sifields._sigfault > > Usually that's heap corruption. For example, the application might > have overrun a buffer overwritten some internal malloc data > structures. > > If you can reproduce it at will, valgrind is a great diagnostic tool > for such issues. > >> I tried to create a test case, but got slightly different messages, they >> actually vary. Is there a gdb bug if the same program has different >> backtraces? >> GNU gdb (Ubuntu 8.1-0ubuntu3) 8.1.0.20180409-git >> >> Core was generated by `./loop'. >> Program terminated with signal SIGSEGV, Segmentation fault. >> #0 0x00007fc10dee51e7 in void std::__cxx11::basic_string> std::char_traits, std::allocator >> >::_M_construct(char*, char*, std::forward_iterator_tag) () >> from /usr/lib/x86_64-linux-gnu/libstdc++.so.6 >> (gdb) bt >> #0 0x00007fc10dee51e7 in void std::__cxx11::basic_string> std::char_traits, std::allocator >> >::_M_construct(char*, char*, std::forward_iterator_tag) () >> from /usr/lib/x86_64-linux-gnu/libstdc++.so.6 >> #1 0x00005592fbb669d7 in func (f="a", g=0) at loop.cpp:7 >> #2 0x00005592fbb669e8 in func (f="a", g=0) at loop.cpp:7 >> #3 0x00005592fbb669e8 in func (f="a", g=0) at loop.cpp:7 > > This looks like a very different thing. Due to the deep recursion, > the code faults when accessing the guard page below the stack. > Thanks for your reply Florian. I guess I was just expecting GCC to generate code that avoided overrunning the stack (or heap) and exiting gracefully. I don't know if that is gcc, glibc, or kernel. Or if it's just down the program! I'll look into this a bit more. Jonny