Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

GDB crashes at start (internal error: follow_die_offset)

Tags:

c++

linux

gdb

I have a small C++ project under Linux. When I try to debug the executable with gdb I get the following error:

../../gdb/dwarf2read.c:16760: internal-error: follow_die_offset:
Assertion 'dwarf2_per_objfile->reading_partial_symbols' failed.
A problem internal to GDB has been detected,
further debugging may prove unreliable.

I have strongly simplified the project to the following code and still get the same error:

B.h:

#ifndef B_H_
#define B_H_

#include <vector>
class B {
public:
    B();
    std::vector<double> p;
};

#endif /* B_H_ */

B.cpp:

#include "B.h"
B::B() {}

D.h:

#ifndef D_H_
#define D_H_

#include "E.h"

class D: public E {
public:
    D();
};

#endif /* D_H_ */

D.cpp:

#include "D.h"

D::D() : E() {}

E.h:

#ifndef E_H_
#define E_H_

#include <functional>

class E {

public:
    void set(const std::function<double(void)>& f);
    std::function<double(void)> e;

};

#endif /* E_H_ */

E.cpp:

#include "E.h"

void E::set(const std::function<double(void)>& f) {
    e = f;
}

main.cpp:

int main() {}

makefile:

all: Test

%.o: %.cpp
    icpc -c -std=c++11 -g -o $@ $<

Test: main.o D.o E.o B.o
    icpc -std=c++11  -o $@ $^

clean: 
    rm -f D.o E.o B.o Test main.o

.PHONY: all clean 

The error occurs if I do:

gdb Test

and then invoke

run

in the gdb CLI.

My system:

Open Suse 12.3, 64bit

icpc --version:

icpc (ICC) 15.0.1 20141023

icpc -v:

icpc version 15.0.1 (gcc version 4.7.0 compatibility)

gdb --version:

GNU gdb (GDB) SUSE (7.5.1-2.1.1)

gcc --version:

gcc (SUSE Linux) 4.7.2 20130108 [gcc-4_7-branch revision 195012]

I have no idea what is wrong with the given code and why the debugger crashes. For example if I comment out the constructor of class B (which does nothing and should be equivalent to the default constructor) the error does not appear anymore.

like image 702
user1304680 Avatar asked Dec 08 '14 09:12

user1304680


2 Answers

See this thread: https://software.intel.com/en-us/forums/topic/540685 -- it seems to be an issue in gdb, fixed in 7.9. UPDATE I upgraded gdb to 7.9 and the problem really went away, for me at least.

like image 182
eudoxos Avatar answered Nov 04 '22 03:11

eudoxos


I have no idea what is wrong with the given code and why the debugger crashes.

There is likely nothing wrong with your code, but your compiler may be generating invalid DWARF debug info, and your somewhat old GDB certainly has a bug dealing with that.

Note that you are using very new icpc with old GDB, so this isn't very surprising.

Your first step should be to build current GDB (7.8.1) and check whether it still has a problem.

In the unlikely case that it does, you should report it in GDB bugzilla.

As a workaround, you may also try building your sources with GCC instead of ICC.

like image 24
Employed Russian Avatar answered Nov 04 '22 02:11

Employed Russian