Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

debugging c++ : ../nptl/sysdeps/unix/sysv/linux/raise.c: No such file or directory

Tags:

c++

gdb

I'm using gdb to debug a C++ program. In the line

assert(prevId ==  GetTagIdFromState(maxState));
  • the parameter prevId value is 0;
  • the method GetTagIdFromState(maxState) returns 50;

when debugging this, I get the following errors.

Assertion `prevId == GetTagIdFromState(maxState)' failed.
Program received signal SIGABRT, Aborted.
0x00007ffff6ecbba5 in raise (sig=<value optimized out>) at ../nptl/sysdeps/unix/sysv/linux/raise.c:64
64    ../nptl/sysdeps/unix/sysv/linux/raise.c: No such file or directory.
      in ../nptl/sysdeps/unix/sysv/linux/raise.c
like image 924
wangzhiju Avatar asked Oct 31 '12 06:10

wangzhiju


2 Answers

Your application works as intended. The assertion fails (since the values you pass to it are not equal, the assert macro receives 0), and thus your program is being aborted. That's how asserts work:

If NDEBUG is not defined, then assert checks if its argument (which must have scalar type) compares equal to zero. If it does, assert outputs implementation-specific diagnostic information on the standard error output and calls std::abort.

emphasis mine.

Check this assert reference for further information.

like image 55
SingerOfTheFall Avatar answered Oct 31 '22 07:10

SingerOfTheFall


I just encountered this error while trying to debug a program on a Raspberry Pi. The program happens to use the GPIO in a manner that requires that the program be run as root. For example, I run the program I wrote like this:

sudo ./foo

I forgot this, however, when starting up the debugger, and tried

gdb foo

And I got the error you seem to have encountered:

Program received signal SIGABRT, Aborted.
0x76cd0f70 in __GI_raise (sig=sig@entry=6) at ../nptl/sysdeps/unix/sysv/linux/raise.c:56
56  ../nptl/sysdeps/unix/sysv/linux/raise.c: No such file or directory.

When I ran it using sudo, it worked fine.

sudo gdb foo

Hope that's helpful to someone in the same boat.

like image 30
Marvo Avatar answered Oct 31 '22 09:10

Marvo