Debug a Qt assert in Visual Studio - c++

I am getting an assert that generates a dialog from Qt to abort, retry, or ignore. Unfortunately, when I retry, it always just goes to app.exec() so I cannot see where the error is coming from, or what inputs may be contributing.
When I debug, I can see all my code and moc code, and all variables and pointers are set appropriately. But when I step into Qt code, I get Qt5Cored.pdb not loaded. I cannot seem to locate the PDB files in my Qt installation either.
The error happens after emitting a signal and all (my) slots have completed successfully.
The error from Qt is so deep in the weeds, it is not helpful:
Debug Error!
Program: Qt5Cored.dll
Module: 5.14.2
File: painting\qoutlinemapper.cpp
Line: 105
ASSERT: '!path.isEmpty()' in file painting\qoutlinemapper.cpp, line 105
(Press Retry to debug the process)
I inspected the source code for the error, but that wasn't terribly helpful, and the debugger will not provide the caller.
I don't know what is the problem since I can't debug, so I can't provide a minimal working example either. All of my code is working as expected, but I am sure I am providing Qt with something inappropriate, but I just do not know what. Any help on how to better debug this issue so I can determine what is causing it would be appreciated.
Interestingly, if I run in release and the assert is bypassed, the applications works exactly as expected with no obvious side effects (I do realize that could just be luck).

Related

Cannot debug my STM32 CubeIDE project anymore, but code works without J-Link

I somehow have fallen in the state where I cannot start in debug mode my project in CubeIDE and J-Link. The code compiles, flash is written, but then instead of stopping on the first instruction in my main function in main.c, I get stuck in the Disassembly part of the project.
In title bar it says "Source not found" and in working window it says:
Break at address "0x20011b88" with no debug information available, or outside of program code.
Disassembly on this address shows:
20011b88: bkpt 0x0000
but step into pops up the window with:
Failed to execute MI command: -exec-step 1 Error message from debugger back end; Cannot find bounds of current function
I must be missing something obvious here, and will appreciate any guidance.
Also some pointers, where to study, how project debuging is started in details, will be welcomed.

How to make QtCreator show "normal" code while debugging instead of assembly?

I am using QtCreator 3.6.1 on Ubuntu 14.04 with gcc as my main compiler.
My Qt project is being built in debug mode. However, whenever I press F5, to try to step into the code by setting break points, my code crashes (since the code is buggy) but instead of stopping at the breakpoint, it shows me assembly output!
Here is a screen shot. The code seems to have crashed at where you see the yellow arrow, but I just don't know where in the source code it is!!!
In fact, I have set my breakpoint at a cout statement as you can see here.
Not even the cout statement is executing. The code seems to be crashing before main is executed. I don't know if this is QtCReator problem or something else. I have added -O0 and -g option
to the QMAKE_CXXFLAGS option just to be sure, that debugging symbols are being added, yet I get this problem.
EDIT:
My stack trace looks like this
Also I am not sure if this helps, but when I run the program through the terminal with LD_DEBUG in front of the program's name, I get a huge amount of output.
The last three lines are
.
.
.
7934: symbol=_ZN11QMetaObject8addGuardEPP7QObject; lookup in file=/usr/lib/x86_64-linux-gnu/libQtGui.so.4 [0]
7934: symbol=_ZN11QMetaObject8addGuardEPP7QObject; lookup in file=/usr/lib/x86_64-linux-gnu/libQtCore.so.4 [0]
7934: binding file /usr/lib/x86_64-linux-gnu/libQtGui.so.4 [0] to /usr/lib/x86_64-linux-gnu/libQtCore.so.4 [0]: normal symbol `_ZN11QMetaObject8addGuardEPP7QObject'
[1] 7934 segmentation fault (core dumped) LD_DEBUG=all ./CGALQT_Fix_MainWindow
for this, your application has to link to debug libraries. To investigate where your app crashes, you don't usually need this because you can see all of your own methods in function stack.

Cannot debug with gdb in ubuntu

Qt creator throws an error every time I want to start debugging. Here is the error:
ptrace: Operation not permitted.
Could not attach to the process. Make sure no other debugger traces this process.
Check the settings of
/proc/sys/kernel/yama/ptrace_scope
For more details, see /etc/sysctl.d/10-ptrace.conf
I have googled the error message and got some result about bug in the kernel but I am able to run gdb in command line, so I don't think it is kernel/gdb related.
What can be the cause of this error?
I just did some research and found the solution somewhere. It turns out that /proc/sys/kernel/yama/ptrace_scope was set to 1. After I changed it to 0, the problem disappeared.
Explanations of ptrace can be found here and here, as Merlin069 said.

Qt Creator - Code is running but I get an error message from the IDE

As soon as I run my code (note that I'm using C only, no QT and no C++) I get the following message from the application output inside the IDE:
Cannot obtain a handle to the inferior: The parameter is incorrect.
When I delete the makefiles and debug/release folders it's running but after some time I still get the error. It's not that much of a problem though, the code runs and everything is fine but this error pops up and it's quite annoying.
The content of the .pro file is:
TEMPLATE = app
CONFIG += console
CONFIG -= app_bundle
CONFIG -= qt
QMAKE_CC = gcc -std=c99
SOURCES += main.c
Thanks in advance!
edit: I have added C++ tag, because this error occurs also for C++ console application as in my case.
I have met same problem. Tips and advices on forums are rather clueless, so I investigated problem myself and I have found that it's a bug in QtCreator.
There is dirty little program called qtcreator_process_stub. Whenever you run your program within IDE, IDE first runs qtcreator_process_stub and passes your program name as parameter (among some other parameters). qtcreator_process_stub then starts your program as separate process and prints its PID (and on windows also thread id). Information is printed to the pipe and then it is read by ConsoleProcess::readStubOutput(), which is part of Utils.dll library used by QtCreator.
The problem occurs when "inferior" process (your application) finishes execution before whole communication has been processed. ConsoleProcess::readStubOutput() attempts to use OpenProcess() on non-existing process with closed handle. OpenProcess() fails hence error "Cannot obtain a handle to the inferior: The parameter is incorrect.". Whole error is not handled very gently (Uhm, and now what?)... :-/
Solution:
When you add some user input action, pause, sleep, delay or just some loops, so that execution of your application is a bit longer error vanishes. There is enough time for ConsoleProcess::readStubOutput() to execute OpenProcess(), before your application quits. So as a workaroud I suggest to do that until the bug is fixed.
I got the same error repeatedly while working on a C++ project in Qt. I was able to solve it by copying one of the shared libraries(.dll) I was using in to the build folder.
So, if you are using any shared external libraries that are needed at runtime, make sure they are in the builds folder.

Strange "No such file or directory" error in cuda-gdb

I already asked this question in the nvidia forum but never got an answer link.
Every time I try to step into a kernel I get a similar error message to this:
__device_stub__Z10bitreversePj (__par0=0x110000) at
/tmp/tmpxft_00005d4b_00000000-1_bitreverse.cudafe1.stub.c:10
10 /tmp/tmpxft_00005d4b_00000000-1_bitreverse.cudafe1.stub.c: No such file or directory.
in /tmp/tmpxft_00005d4b_00000000-1_bitreverse.cudafe1.stub.c
I tried to follow the instructions of the cuda-gdb walkthrough by the error stays.
Has somebody a tip what could cause this behaviour?
The "device stub" for bitreverse(unsigned int*) (whatever that is) was compiled with debug info, and it was located in /tmp/tmpxft_00005d4b_00000000-1_bitreverse.cudafe1.stub.c (which was likely machine-generated).
The "No such file" error is telling you that that file is not (or no longer) present on your system, but this is not an error; GDB just can't show you the source.
This should not prevent you from stepping further, or from setting breakpoints in other functions and continuing.
I was able to solve this problem by using -keep flag on the nvcc compiler. This specifies that the compiler should keep all intermediate files created during the compilation, including the stub.c files created by cudafe that are needed for the debugger to step through kernel functions. Otherwise the intermediate files seem to get deleted by default at the end of the compilation and the debugger will not be able to find them. You can specify a directory for the intermediate files as well, and will need to point your debugger (cuda-gdb, nsight, etc) to this location.
I think I had such problem once, but can't really remember what was it caused with. Do you use textures in your kernel? In that case you couldn't debug it.