Visual Studio Debug Error - multithreading

I recently added some multi-threading to my project. Now, I am getting the following error in debug mode:
Debug Error!
Program: C:\src\grok-build\bin\Debug\opj_decompress.exe
abort() has been called
(Press Retry to debug the application)
The program '[20468] opj_decompress.exe' has exited with code 0 (0x0).
Unfortunately, I don't get the dialog popping up allowing me to debug the program, it simply just exits. How can I find the problem here ?
Thanks!

Turns out I was not joining the threads before exiting.

Related

How can I see my compiler errors/warnings in Android Studio 3.01?

In my program, I'm trying to send an http get request. I have a lot of errors, but I don't know where specifically they occur. How do I open the compiler error window? And is this different than the typical debugging in Android Studio where you set a breakpoint in your code?
Thanks a lot for the help!
Usually, I use "messages" tab to see the compile errors that can be accessed using the Alt+0 shortcut. I also recommend you read the "Event log" too.
But if you want to read run time execution errors, you can open the "Logcat" tab or Alt+6.
Attention, do not confuse compile errors (syntax errors) with run time executions errors (semantic errors, request errors, etc).

C++ program crashes before theApp::InitInstance()

Visual C++ 2005 Professional
Debug/Win32
Windows 7 Enterprise 64-bit
I set a breakpoint at my program's entrypoint. My program crashes before reaching that breakpoint. When the unhandled exception occurs (Access violation reading location 0x00000000.), I click on Break, and set a breakpoint where the current instruction pointer is located. Restart the debugging session and the program stops on the new breakpoint. I scroll up to the top of the current function, __tmainCRTStartup(), and set a breakpoint at the opening brace for the function.
I stop/restart the debugger again, this time stopping at __tmainCRTStartup(). By this time, all of the DLL's have been loaded, and if they needed to, run their load functions. Press [F5] to run to the original breakpoint. The Next Statement pointer is pointing at a call to WinMain(...).
Stepping over this statement causes the unhandled exception. Stepping into the statement takes me to this statement: "return AfxWinMain(hInstance, hPrevInstance, lpCmdLine, nCmdShow);". Stepping into once again takes me to the Disassembly window, where I see the next statement to run: "jmp AfxWinMain (563AFAh)".
I can step through the assembly code, but I cannot make out what it is trying to do before it tries to dereference a pointer in one of the registers, which holds a value of zero (0).
I read another post about a C program crashing before reaching main(). Even though tagged with "C", many responders mentioned constructors of a static instance of a class being a possible culprit. Others mentioned DLL's loading and running their own startup code that might crash the program, but the DLL's all seem to load and I have evidence of at least one DLL running its startup code, before the program gets to __tmainCRTSetup() .
Can anyone help me understand this? Knowing why it's doing this should help me understand how to fix it.
Thank you!

Visual C++ Debugging Error - wuser32.pdb not loaded

I have made a form (GUI) in Visual C++ & while debugging it step by step, I got the following error, which stopped further debugging of the code.
The screenshot of the error is shown below.
How to solve this?
Good chance further debugging is in fact not stopped - seems you tried to step into a system function (implemented in wuser32.dll), and you can't debug this without matching symbols. You can post a screenshot of the stack window at this point to help us verify.
First, try to just continue (F5 or Shift+F11 to step out).
If for some reason you must view at least function names at this location - check the 'microsoft symbol server' at the screen you show. and click load. After a brief download pause, you should be able to see at least a disassembly window, and hopefully a meaningful name for the current stack frame.

Debugging Multithreaded C++ program in Visual Studio 2008

I am debugging a multi-threaded program in Visual Studio 2008.
When I break in the main thread, what is the status of the other threads in the process ?
They keep executing or they break as well ?
What happens to them when I do a F10/F11 in the main thread ?
How should I proceed if I need to check which thread has changed a particular variable ?
If the debugger breaks into the process (for example via Breakpoints or "Break All"), then all threads a get suspended.
If the press F10 or F11, then a new "temporary" breakpoint is added to the next line and the process is started (resumed) again. Therefore all threads runt (for a very short time), until the breakpoint is hit.
If you need to detect how is changing a variable, you can set a "Data-Breakpoint". For a reference see What are data breakpoints?
Also take a look at the documentation: How to: Set a Data Breakpoint
Also please be aware, that you can see the list of threads by opening the "Threads"-Window (Debug|Windows|Threads)!

LINK : fatal error LNK1104: cannot open .exe

My question is not a duplicate of this, in fact its a extension of the same question,
This is the code snippet, due to which the error occurs,
BOOL CMyApp::InitInstance() {
m_pMainWnd = new CMainWindow;
m_pMainWnd->ShowWindow(SW_NORMAL);
m_pMainWnd->UpdateWindow();
return TRUE;
}
So, when I use m_pMainWnd->ShowWindow(SW_NORMAL); the prgoram runs without any error, the window opens in normal size and I can see the output, but when I do m_pMainWnd->ShowWindow(SW_MAX); even after the program runs without errors I cannot see the output window, also when I try to rebuild, VC throws an error saying
LINK : fatal error LNK1104: cannot open .exe
I have followed a few answers of this question as well, the first answer in this question suggests
You might have not closed the the output. Close the output, clean and rebuild the file. You might be able to run the file now.
which is quite correct but what I have to do is log off my computer and log in again in order to terminate the output process, I have to do this because I can neither find an application window that is open, nor I can see any program running in the Application's tab in 'Task Manager'. I even followed the second answer which says
You have to put Application Experience on Manual startup(you can do it by searching services in windows 7 start menu, and then find Application Experience and click properties).
except when I got there, I found the Application was already put on Manual Startup, and the problem still persists. Along with the solution what I want to know is why does the program not show output when I write m_pMainWnd->ShowWindow(SW_MAX);
If it helps I am using VC++ 6.0 and my OS is Windows-7 Professional 32-bit
SW_MAX is same as SW_FORCEMINIMIZE the documentation states that
Minimizes a window, even if the thread that owns the window is not
responding. This flag should only be used when minimizing windows from
a different thread.
It infact minimize the window and the application still run's in the task bar. I checked it in Win7 machine.
if your objective is to display the window in maximized state use SW_SHOWMAXIMIZED instead.
The VC++ 6.0 debugger does not work correctly under Windows 7 due to changes.
When you attempt to kill the process from the debugger, the process doesn't end correctly and gets stuck.
See the following topic for more info.
How to debug with Visual C++ 6 on Windows 7 x64?

Resources