The gdb process terminated unexpectedly. Error codes - c++

I'm having this message: The gdb process terminated unexpectedly (code 3) while debugging a plain C++ application at Qt Creator.
The problem is that sometimes gdb crashes and sometimes it works. The application consists of one file: main.cpp.
If I use Code::Blocks, the application works.
The problem is connected with my code, because I've never had this error before.
I have 2 questions:
Where can I find information about the meaning of the error codes? What does code 3 mean?
How can we cause this gdb error by "bad code"? We can easily cause run-time or compiler error, but how can we make gdb to crash?
Thanks so much for answers

Related

Debugging gdb: exit code 139 in VSCode

I am working on a large codebase and trying to debug the same using gdb(C/C++) extension on VSCode.
On running a particular configuration, I get an error with exit code 139. I know this is a segmentation fault, but am unable to exactly pinpoint where the seg fault is occurring. Is there any way I can monitor that?
Probably some file that I am missing where the details are being captured?
I can debug segfault using gdb from the terminal. But since the code requires certain configurations and is spread over hundreds of files, I am not sure how to do that.

Debug huge C++ project on linux

I developed a project on Mac using C++. It works perfectly. However when I try to launch it from a Linux server, I get a bad alloc error:
terminate called after throwing an instance of 'std::bad_alloc'
what(): std::bad_alloc
Aborted
I don't know how to debug the whole project because I have absolutely no idea of where the issue come from. Why is it working on my Mac and not on Linux? All articles and questions about that only ask for single file program but not 40+ files project.
Is there a way to get the file or line that causes the bad alloc?
Build your program with the -g compiler option to get meaningful stack traces.
Then run the program in a debugger, e.g. gdb:
gdb --args [executable] [arguments...]
When gdb has loaded, enter the command run and you program will be run. As soon as the exception is thrown and not caught by your program, gdb will show you a stack trace showing you from where the exception was thrown.
std::bad_alloc means that your program wasn't able to allocate any more memory, probably because the OS either ran out of memory or you hit an explicit memory limit imposed by the system.

Xcode Error using Pthread: Thread 2 Signal SIGABRT

I tried doing some Googling on this issue, but it seems most people have SIGABRT errors when working on iOS apps in Xcode. My issue is related to a concurrent C++ terminal application. I am getting the error Thread 2 Signal SIGABRT on random runs of my software and it is always on a pthread_mutex_lock() or pthread_mutex_unlock() calls. Are there any known issues with Pthread in this regard or does this error directly come down to user error? I would like to post some code, but I currently don't have the right to. I was hoping someone who is familiar with Pthread can tell me if this is an issue with the library or not.
Also, when I run the binary outside of Xcode through terminal, I sometimes get an abort trap: 6 error when using similar inputs that I use to trigger the SIGABRT error in Xcode. Are these definitely two separate errors, or could they be linked?

Breakpoint installation failed: Interrupt failed

I'm using Eclipse Mars and trying to debug a C++ file. I'm adding a breakpoint to a line, but after a few seconds I get the warning:
Breakpoint installation failed: Interrupt failed.
And the debugger doesn't stop at that point even though I know for sure that the code does reach the line with the breakpoint.
What can be done to solve this issue?
This messages indicates that the source file where you set the breakpoint does not belong to the actual binary you are debugging
The error message says: "interrupt failed". This does not seems to be a problem with matching binary with source file, it is rather a problem with GDB not being able to interrupt the process. My suggestion is to restart the debugger and set the breakpoint before the program actually starts.
I have this error sometimes when I debug a C++ multithreaded program in Eclipse.
Although I hadn't encountered such a problem with Eclipse, my suggestion is to look to Eclipse forum following these links:
https://www.eclipse.org/forums/index.php?t=tree&th=201329#page_top
https://bugs.eclipse.org/bugs/show_bug.cgi?id=331833
Make sure that "Skip All Breakpoints" is not enabled!
skip breakpoints button
I've had this warning on Eclipse TrueStudio Atollic. It didn't hamper at all my debugging. I rebuilt, checked breakpoint properties unsuccesfully. Then I remained in Eclipse ide, closed the project, reopened it and the warning had disappeared.

Visual Studio 2012 Release only error

There are a number of errors going on here but I'm sure they are all linked, so first off I'm getting Access violation reading location exceptions at locations (generally near 0x00000000)
but I only get these exceptions in release and not in debug, even if i setup debugging to do so. Also I found where the error happens but when I step over that it goes in to a complete unrelated function that is not called in the line or in any of the functions in that line of code. But when similar code is called it still goes to this unrelated function but doesn't fail. This all only happens in release versions. I know which piece of code is causing the error as if I comment it out its all fine. Also in the watch window in release all the numbers are wrong most of the time, which has never been a problem but it could help also a added some code to it to output the values of variables to a file and the variables are all fine, the pointers are sensible, but when the exception happens it always says their 0x00000020 but when I look at the log they are fine. This is in 32 bit , but on 64 bit windows 7 in c++. Please any help would be good!
Visual Studio's debugger will cause the program to use a debug heap that can hide uninitialized memory if you use the option "Start with Debugging" to start your program, in release or debug. You can try to run your program built in the Debug configuration without the debugger attached, and then use the Attach to Process... option in the debug menu to attach to your executable.
If this doesn't help, I recommend using windbg to debug your program. For help getting started with windbg, take a look at the answers on this question.
Once windbg is configured and symbol paths are set up, you can use the "!analyze -v" option once the program crashes to get a lot of information about the crash automatically.