From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 10480 invoked by alias); 19 Mar 2019 22:05:06 -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 10469 invoked by uid 89); 19 Mar 2019 22:05:06 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-2.7 required=5.0 tests=AWL,BAYES_00 autolearn=ham version=3.3.1 spammy=grant, Grant, Due, faults X-HELO: albireo.enyo.de Received: from albireo.enyo.de (HELO albireo.enyo.de) (5.158.152.32) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Tue, 19 Mar 2019 22:05:04 +0000 Received: from [172.17.203.2] (helo=deneb.enyo.de) by albireo.enyo.de with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) id 1h6Mr0-0005lV-8q; Tue, 19 Mar 2019 22:05:02 +0000 Received: from fw by deneb.enyo.de with local (Exim 4.92) (envelope-from ) id 1h6Mr0-0005iw-5Q; Tue, 19 Mar 2019 23:05:02 +0100 From: Florian Weimer To: Jonny Grant Cc: gcc-help Subject: Re: Recursive SIGSEGV question References: <1255ee27-882f-ab4e-ea45-ba6f35791b45@jguk.org> Date: Wed, 20 Mar 2019 04:02:00 -0000 In-Reply-To: <1255ee27-882f-ab4e-ea45-ba6f35791b45@jguk.org> (Jonny Grant's message of "Tue, 19 Mar 2019 21:31:13 +0000") Message-ID: <877ecuikq9.fsf@mid.deneb.enyo.de> MIME-Version: 1.0 Content-Type: text/plain X-IsSubscribed: yes X-SW-Source: 2019-03/txt/msg00119.txt.bz2 * 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.