Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

gdb seg faults when reading symbols

When trying to run gdb with a program, it seg faults while reading symbols.

When I run:

gdb /home/user/path/to/program.exe

I get:

GNU gdb (Ubuntu 7.7-0ubuntu3.1) 7.7
Copyright (C) 2014 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.  Type "show copying"
and "show warranty" for details.
This GDB was configured as "x86_64-linux-gnu".
Type "show configuration" for configuration details.
For bug reporting instructions, please see:
<http://www.gnu.org/software/gdb/bugs/>.
Find the GDB manual and other documentation resources online at:
<http://www.gnu.org/software/gdb/documentation/>.
For help, type "help".
Type "apropos word" to search for commands related to "word"...
Reading symbols from /home/user/path/to/program.exe...Segmentation fault (core dumped)

I suspect that the binary might be too large for gdb to load into memory. This error only occurs when I compile with -g (debug flag). Here's the difference in size of the binaries:

Compiled with

-release flag: 405 MB

-debug flag: 862 MB

Any ideas on other culprits of this segmentation fault? Or is there a way to increase the memory allowed for gdb? This turns out to be a very challenging problem to google.

like image 830
StrugglingProgrammer Avatar asked Jun 03 '14 20:06

StrugglingProgrammer


People also ask

How can segmentation fault be prevented?

Use a #define or the sizeof operator at all places where the array length is used. Improper handling of NULL terminated strings. Forgetting to allocate space for the terminating NULL character. Forgetting to set the terminating NULL character.

What causes segmentation fault core dumped C?

Core Dump (Segmentation fault) in C/C++ It happens due to reasons like when code tries to write on read only memory or tries to access corrupt memory location.


1 Answers

I was having the same problem with gdb 7.9 on Ubuntu 15.04 x86_64, which I had installed simply using apt-get install gdb.

I solved the problem by compiling and installing a previous version: gdb 7.5.1.

I had to download a library (which I found out here) and I also had to run ./configure using some arguments (which I found out here). Everything else is straightforward.

Good luck.

Here are the commands:

$ cd
$ sudo apt-get install libncurses5-dev
$ wget ftp://sourceware.org/pub/gdb/releases/gdb-7.5.1.tar.gz
$ tar zxf gdb-7.5.1.tar.gz
$ cd gdb-7.5.1
$ sudo ./configure --disable-werror
$ sudo make
$ sudo make install
like image 73
Girardi Avatar answered Sep 30 '22 05:09

Girardi