public inbox for gcc-help@gcc.gnu.org
 help / color / mirror / Atom feed
From: Jonny Grant <jg@jguk.org>
To: gcc-help <gcc-help@gcc.gnu.org>
Subject: Recursive SIGSEGV question
Date: Tue, 19 Mar 2019 22:05:00 -0000	[thread overview]
Message-ID: <1255ee27-882f-ab4e-ea45-ba6f35791b45@jguk.org> (raw)

[-- Attachment #1: Type: text/plain, Size: 3816 bytes --]

Hello

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 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



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<char, 
std::char_traits<char>, std::allocator<char> 
 >::_M_construct<char*>(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<char, 
std::char_traits<char>, std::allocator<char> 
 >::_M_construct<char*>(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



The backtrace seems to vary, is this possibly a GDB bug?


Core was generated by `./loop'.
Program terminated with signal SIGSEGV, Segmentation fault.
#0  0x00005615cc3549ae in func (
     f=<error reading variable: Cannot access memory at address 
0x7ffe87dfefd8>,
     g=<error reading variable: Cannot access memory at address 
0x7ffe87dfefd4>) at loop.cpp:6
6	{
(gdb) bt
#0  0x00005615cc3549ae in func (
     f=<error reading variable: Cannot access memory at address 
0x7ffe87dfefd8>,
     g=<error reading variable: Cannot access memory at address 
0x7ffe87dfefd4>) at loop.cpp:6
#1  0x00005615cc354a03 in func (f="a", g=0) at loop.cpp:7
#2  0x00005615cc354a03 in func (f="a", g=0) at loop.cpp:7
#3  0x00005615cc354a03 in func (f="a", g=0) at loop.cpp:7
#4  0x00005615cc354a03 in func (f="a", g=0) at loop.cpp:7



Core was generated by `./loop'.
Program terminated with signal SIGSEGV, Segmentation fault.
#0  0x0000559924c939ae in func (
     f=<error reading variable: Cannot access memory at address 
0x7ffe76f8bfe8>,
     g=<error reading variable: Cannot access memory at address 
0x7ffe76f8bfe4>) at loop.cpp:6
6	{
(gdb) bt
#0  0x0000559924c939ae in func (
     f=<error reading variable: Cannot access memory at address 
0x7ffe76f8bfe8>,
     g=<error reading variable: Cannot access memory at address 
0x7ffe76f8bfe4>) at loop.cpp:6
#1  0x0000559924c93a03 in func (f="a", g=0) at loop.cpp:7
#2  0x0000559924c93a03 in func (f="a", g=0) at loop.cpp:7
#3  0x0000559924c93a03 in func (f="a", g=0) at loop.cpp:7
#4  0x0000559924c93a03 in func (f="a", g=0) at loop.cpp:7
#5  0x0000559924c93a03 in func (f="a", g=0) at loop.cpp:7
#6  0x0000559924c93a03 in func (f="a", g=0) at loop.cpp:7
#7  0x0000559924c93a03 in func (f="a", g=0) at loop.cpp:7

Jonny

[-- Attachment #2: loop.cpp --]
[-- Type: text/x-c++src, Size: 189 bytes --]

// g++-8 -g -ggdb -O0 -Wall -Wextra -o loop loop.cpp

#include <string>

static void func(std::string f, int g)
{
    func(f.c_str(), g);
}

int main()
{
    func("a", 0);

    return 0;
}

             reply	other threads:[~2019-03-19 21:31 UTC|newest]

Thread overview: 31+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-03-19 22:05 Jonny Grant [this message]
2019-03-20  4:02 ` Florian Weimer
2019-03-20  8:11   ` Jonny Grant
2019-03-25 13:23   ` Jonny Grant
2019-03-25 13:27     ` Jonathan Wakely
2019-03-25 13:56     ` Florian Weimer
2019-03-25 14:01     ` Xi Ruoyao
2019-03-25 15:47       ` Florian Weimer
2019-03-25 16:10         ` Andrew Haley
2019-03-25 16:13           ` Jonny Grant
2019-03-25 16:23             ` Jonathan Wakely
2019-03-25 18:51           ` Florian Weimer
2019-03-25 20:39             ` Jonny Grant
2019-03-26  6:50               ` Xi Ruoyao
2019-03-27  0:29                 ` Jonathan Wakely
2019-03-27 21:34             ` Jonny Grant
2019-03-27 23:43               ` Jonathan Wakely
2019-03-27 23:51                 ` Jonny Grant
2019-03-28  8:26                   ` Xi Ruoyao
2019-03-28 11:52                     ` Jonathan Wakely
2019-03-29  2:24                     ` Jonny Grant
2019-03-30 17:32                       ` Jonny Grant
2023-02-19 21:21                       ` Jonny Grant
2023-02-19 21:34                         ` Jonny Grant
2019-03-28 13:55                   ` Jonathan Wakely
2019-03-28 14:39                     ` Jonny Grant
2019-03-28 14:39                       ` Jonathan Wakely
2019-03-25 20:28         ` Segher Boessenkool
2019-03-25 18:56       ` Segher Boessenkool
2019-03-25 22:05       ` Jonny Grant
2019-03-26 10:20         ` Xi Ruoyao

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=1255ee27-882f-ab4e-ea45-ba6f35791b45@jguk.org \
    --to=jg@jguk.org \
    --cc=gcc-help@gcc.gnu.org \
    /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).