Click here to Skip to main content
15,891,473 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hello,

My C++ program (console application)is stuck even before it get to the main() function (the console is open, and nothing happens).
(I check with VS6 and VS2010 and got the same problem)
This problem started after I changed one of the libraries that I use.

What can be the reason for this problem (the libraries, related dlls?)
How can I check where the program is stuck? Are there any recommended tools to check it?

Thanks,
Dotan Knaan
Posted

Use a debugger and get stack traces for all the threads.
 
Share this answer
 
v2
Comments
Andrew Brock 2-Feb-11 8:21am    
Only the main thread should be affecting it, since that is where the main() function lives. Although it is possible that a second thread is taking a Mutex or the likes and not letting the main thread take a hold of it.
It will most likely be a global variable (of a class) initialising.

All global variables are initialised as part of the CRT startup, before the code enters the main() function (and cleaned up after the main() function returns)

Start debugging and let it run for a few seconds, then hit pause on the debugger. The debugger will break and show you where it is currently up to. At a guess it will be either an infinite loop or waiting on something like a Mutex or Semaphore
 
Share this answer
 
Comments
DotanKnaan 2-Feb-11 16:09pm    
Thanks for the answer.
I paused the debugger, and the stack is at: NTDLL! 7c90e514()
A bit lower in the list I see: " _initterm(void (void)* * 0x10134128, void (void)* * 0x10134230) line 525 ". I don't know this function. It's probably inside the library that I use.

Can I understand from this information anything about the source of my problem?

Thanks again
Emilio Garavaglia 3-Feb-11 16:22pm    
_initterm is the function that fills-up the chain of constructors and destructors of the global objects, to be called in turn before entering and just after leaving main.
The two parameters are the addresses of a constructor and a destructor.

Most likely, above _initterm there is a constructor spinning in an endless loop.
Andrew Brock 4-Feb-11 2:04am    
I'm going to assume that you are running Windows XP as ntdll is not based at 0x7C900000 in Windows 7.
In my Windows XPSP3 that address belongs to the function RtlRaiseException (although it doesn't match up exactly). Check the Output Window to see if there is any messages (exceptions in particular) printed.
DotanKnaan 4-Feb-11 4:56am    
Thanks for the information. I will check it. Thanks!
When you run in the development environment you can simply pause the program and see in the stack window (Ctrl-Alt-C) where it is running at the time of pausing. This would give you some info on which method with the file and that be where the problem is (probably).

Good luck!
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900