I'm using gdb
to debug a C++
program. In the line
assert(prevId == GetTagIdFromState(maxState));
prevId
value is 0
; GetTagIdFromState(maxState)
return
s 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
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.
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With