Sign in to follow this  

[C++/Win32] Can't stop!

This topic is 2847 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Visual C++ 2008 Pro When I return from WinMain(), my IDE still understands the app is running unless I click Stop on the debug runtime toolbar. I literally hold the instruction pointer's hand until I step out of WinMain itself. The IDE still has the window name with "(Running)" and awaits manual termination (of something). I have no memory leaks and I don't see any problematic usage of anything. However, the IDE behaves fine if I just return from WinMain straight away so I'm the bad guy. I cannot hope to ask you guys to look at my project since there is no clue where to begin, but have any of you had this problem before? Please tell me about it, because otherwise I am guaranteed several hours of digging. I have little idea where to look, so I'm looking for any shortcuts I can find.

Share this post


Link to post
Share on other sites
I'm trying to find what part may even be provoking this behavior.
I'll get back with some more info as soon as I can. Right now the tread is open just in case someone else knew how to fix something like this, meaning they may have made a similar mistake.

And no, no threads... I think. FMOD might, so I'll check on that.

Share this post


Link to post
Share on other sites
Click the pause debug command and see what is executing. WinMain isn't the very last thing, there is a bunch of stuff below that. For example, destructors of globals are called after main returns. You might have an infinite loop or a deadlock in one of those.

Share this post


Link to post
Share on other sites
Just wanted to add that while your problem may or may not be thread related, simply having other threads running cannot cause the process to not exit.

This is because after WinMain returns, and after the C runtime library has done its cleanup, ExitProcess is called. ExitProcess doesn't care how many threads you have running.

Quote:
From MSDN
The ExitProcess function ends a process and all its threads.

Share this post


Link to post
Share on other sites
Go back in time using your version control system to find when this first started happening. Look at what changed between the this version and the next. If you aren't using a version control system yet, start now.

One thing to check: destructors of objects in static storage going in to infinite loops.

Share this post


Link to post
Share on other sites
Quote:
One thing to check: destructors of objects in static storage going in to infinite loops.


Got it! Thanks for the tip, as that looks to be what happened. I could not step over a std::vector::clear() in a destructor. Additional deduction led me to find my recent changes to a smart pointer design was flawed.

I reserved the 2 high order bits in each reference counter for flags. My original test to see if the counter hit 0 looked like this.

!((--counter)<<2)

This test was unreliable, and the poor thing went about trying to use delete in an, ahem, unorthodox manner. I switched over to a bit-mask and the problem went away. (On first glance) I'm rereading the code to be safe.

Share this post


Link to post
Share on other sites
Quote:
Original post by Melekor
I believe I was the first one to mention that possibility.


I only wrote that as an afterthought, actually. My main point was to emphasize that if version control was used, the OP probably wouldn't be in this situation.

Rest assured that no points were intercepted, though :)

Share this post


Link to post
Share on other sites
I see that you solved the problem, but I recently came across the same problem myself and it had a different solution.

What I was doing was setting the entry point in the Project Preferences->Configuration Properties->Linker->Advanced to WinMain. It *SEEMED* like the logical thing to do. However, doing so prevented the application from shutting down. Leaving this field blank solved this.

Share this post


Link to post
Share on other sites
Quote:
Just wanted to add that while your problem may or may not be thread related, simply having other threads running cannot cause the process to not exit.


A process doesn't exit until all threads have terminated.

Share this post


Link to post
Share on other sites

This topic is 2847 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this