Program hangs in Xcode debugger, but not in Instruments - c++

I'm working on debugging a game written in C++ and it recently started hanging on the splash screen when I try to run it in Xcode (in Debug mode). I can't identify any changes in my code that could have caused this, and there aren't any log messages being printed while this hang is happening (something that I know can severely slow down a program). I then opened Instruments and used the time profiler to try and find the source of the problem, but when I ran my program on the time profiler it progressed past the part where it hangs, and ran as expected. Both running and profiling are set to use Debug mode so the build is the same, does anyone know what could possibly cause an issue like this?
More info: I'm using LLVM/Clang as the compiler and LLDB as the debugger. Looking at Activity Monitor during the hang I can see the game is shown as 'not responding' and Xcode is using a lot of CPU activity, despite not printing any log messages etc.. In 'Edit Schemes' the Profile scheme is set to use the Run action's arguments and environment variables.

Related

C++ / Unkillable process / Can't debug

I've created a small parser that generates an internal representation of an expression from a string. It does compile correctly, but i just can't debug it. When i try to run it, whether it's in debug mode or not, the console pops-up and immediatly closes. In my process list, the program still appears, using 0% cpu and 100 Ko memory, and there is just no way to kill it except by restarting my PC.
The first time i tred using code blocks with the mingw compiler, and the second time i tried using visual studio 2012, but in both case i got the same problem. When trying to run it with VS it showed an error message saying something like "abort has been called".
I can provide the source code if really needed. I'm not using anything extraordinary in it, just pure standard C++ language and iosream to display results and errors in a console.
What can this be due ?
Thanks for your help :)

Getting debug output from a crashed VS2010 application

Question: Can I set up VS2010 so it automatically writes debug output to a file?
Motivation: I have a DirectX 9 application that I'm trying to debug. I've noticed that when my application is fullscreen, it may crash under certain conditions. Normally I would just check my logs or DirectX debug output. However, the way my program crashes prevents that. It freezes and does not respond to any my attempts to end it (including "End Process" from task manager). Moreover, it also freezes my VS2010, and so VS doesn't respond to any commands either. The only way out of this whole thing that I've found is to End VS process. This, however, also destroys the output I'd very much like to read.
Now I see two ways out of this. First is to write all the debug info to a file but I have no idea how to do it. Second is to make my application crash in a more friendly way, but this seems like a difficult task.
Probably MiniDumpWriteMiniDump(..) helps on this. You can at any time dump the current state of the process to a file. After that, you can open the dumps with Visual Studio and analyze the state of the process - this includes callstacks of every thread, variable values...
Try to identify conditions in which your process crashes and write one or more dumps.
Another try is to install the Windows Debugging Tools and use WinDbg to debug your application. This is not as comfortable as Visual Studio, but allows a deeper insight.
Edit:
If there are debug statements made with OutputDebugString(..), you can use DebugView (from Microsoft, earlier Sysinternals) to display it.

C++ application that uses Qt libraries stops working when screen saver starts

I have a C++ application that uses some Qt libraries.
The application works fine until the screen saver pops up and starts.
After that if I quit from screen saver the application crashes and I have to re-start it again. I have tested the application on Windows 7 and XP and this happens on both.
Is there anything I can change in the code so this does not happen?
Luca Carlon give you good and fairly popular advice -- use debugger. In your case, you can get a lot of information about debugging from official documentation.
When you run debug of your program, you must replay situation when your program falls: you must manually start screensaver, or hurry up screensaver to start.
When your program fails -- get back-trace, and try to understand, what was wrong.

Qt application hanging up with 100% CPU

I have a simple Qt program running on Windows XP - its just a data logging program. It reads any data sent to it on the serial port and then it pushes this to the GUI and logs it to a text file.
The thing is, if I run the program for an hour (roughly, sometimes more) it will hang up on me. The GUI locks out and the program stops logging. On the CPU monitor on the performance tab of my task manager, one of my cores always goes straight to 100% when this crash happens and stays there until I close the hung application.
I have literally no experience in diagnosing problems like this - has anyone got any tips on where to start?
Run the application until it freezes and then attach a debugger. Look through the threads and check where each one of them is. This should give some clues on what's going on. For threads that are stopped within framework code an investigation of the call stack should show if your code is involved.
Make sure that you do this on a debug build with all symbols included to get readable results.

App closes while executing after compiling with errors, but while debugging it works fine!

Well. that´s the question. Just that.
I got an app made with SDL and OpenGL. SDL opens an extra window (which is the console) additional to the graphical one. When i execute i´m getting a 3 output error, the console tells me. And it gets closed (the graphical one).
But i know this happens when a SIGSEGV signal is received (don´t know how to capture it) and it appears in my IDE (Code::blocks) while debugging. But this time nothing appears, and everything works all right. But when executing it crashes..
What the...
What kind of error can i expect?. Sometimes it gets closed, sometimes it doesn´t. How to know what kind of problem i got?.
SIGSEGV is a segmentation fault, you're trying to access memory that isn't accessible to your process.
Assuming you're on a UNIXy system, you should be able to get the program to core dump and then look at the core dump in a debugger; alternatively, use a memory debugger like Valgrind to pinpoint the memory management issue that's causing this problem.