Forum C# VS debugger is crashing

VS debugger is crashing

Postby remuo » February 15th, 2011, 11:10 pm

My VS2010 debugger is crashing almost every time i try to debug the program.

I don't have a problem with a specific line of code, wherever i put a breakpoint after some debug-steps it crashes. If i put the breakpoint after the code it crashed before, it executes fine.

One thing i just noticed, is that intellitrace shows this exception, twice, without stopping the debugger itself.

Exception:Thrown: "Could not locate Performance Counter with specified category name 'Memory', counter name 'Free & zero page list bytes'." (System.InvalidOperationException)
A System.InvalidOperationException was thrown: "Could not locate Performance Counter with specified category name 'Memory', counter name 'Free & zero page list bytes'."
remuo
 
Posts: 14
Joined: December 29th, 2010, 6:19 pm

Re: VS debugger is crashing

Postby Oliver » February 18th, 2011, 3:31 pm

Something is wrong. I don't know what.

I don't think it's the exception you mention though... that's probably just the IDE telling you that an exception was thrown.

The code around it is:

Code: Select all
try{
   this.freeMemory = new PerformanceCounter("Memory", "Free & zero page list bytes", "", true);
}catch{
   this.freeMemory = new PerformanceCounter("Memory", "Available Bytes", "", true);
}


As you can see, if we can't find one, we'll use the other one.

What happens if you just start the server without debugging (CTRL-F5) or double click .exe file in Windows Explorer?

- Oliver
User avatar
Oliver
.IO
 
Posts: 1159
Joined: January 12th, 2010, 8:29 am

Re: VS debugger is crashing

Postby remuo » February 18th, 2011, 7:57 pm

Either i start the server with debugging but i don't do any stepping, or start it without debugging, it works fine, without a problem.

I also noticed that the problem appears a lot more when i step-into, than when i step-over.

Also the slower i step, the fewer steps i can do until it freezes. The faster i step, the more steps i can do until it freezes.

When i say it freezes, i mean the 'Test Server.vshost.exe' cpu usage goes to 100%.

I also get a lot of the following messages:
">Warning: Some code has been running for longer than will be allowed in the live enviroment. The code won't be aborted since the debugger is attached, and you might be inspecting game state."

How many of these messages does the test-server normally produce each time it breaks for debugging, because i get A LOT of them. The way i see it, the problem has something to do with these messages.
remuo
 
Posts: 14
Joined: December 29th, 2010, 6:19 pm

Re: VS debugger is crashing

Postby remuo » February 19th, 2011, 11:54 am

Today i got a new error message:

ContextSwitchDeadlock was detected
--------
The CLR has been unable to transition from COM context 0x227ee0 to COM context 0x228108 for 60 seconds. The thread that owns the destination context/apartment is most likely either doing a non pumping wait or processing a very long running operation without pumping Windows messages. This situation generally has a negative performance impact and may even lead to the application becoming non responsive or memory usage accumulating continually over time. To avoid this problem, all single threaded apartment (STA) threads should use pumping wait primitives (such as CoWaitForMultipleHandles) and routinely pump messages during long running operations.
remuo
 
Posts: 14
Joined: December 29th, 2010, 6:19 pm

Re: VS debugger is crashing

Postby Oliver » February 21st, 2011, 10:11 pm

ContextSwitchDeadlock was detected


O_O

How many of these messages does the test-server normally produce each time it breaks for debugging, because i get A LOT of them. The way i see it, the problem has something to do with these messages.


Yes, you'll get a lot of them... around one pr. second.


I cannot replicate it here with visual studio 2010. i tried with waiting 10-20 seconds between each "step into" and it never went beyond 5% cpu... I tried with a 2 minute debugging session.

How long are you in the debugging mode? a minute or much more ?

Do you perhaps have tons of timers running at the same time?

Can you try sending me your game code, then i can try running it and see if there is something special in there provoking the error.

Best,
Oliver
User avatar
Oliver
.IO
 
Posts: 1159
Joined: January 12th, 2010, 8:29 am

Re: VS debugger is crashing

Postby remuo » February 22nd, 2011, 2:28 pm

I saw this 'ContextSwitchDeadlock' only once, so i will leave it for now.

I only use two timers, and it also hangs if i remove them.

I just tried the empty project 'NewGame' that you have in the 'Flash' folder, i just put my game-id and login, it does exactly the same thing. Sometimes it hangs (in the timers commands), sometimes it doesn't.

Then, i put this test code in UserJoined(), just to have something more to step-into:
var test_list = new List<int>();
int test = 0;
for (int i = 0; i < 50; i++)
{
test += test;
test_list.Add(test);
}

It does exactly the same thing, sometimes it hangs in the first timer command, sometimes in the second timer, sometimes in my test code, sometimes it doesn't hang.

I also noticed that before it hangs with 100% cpu usage, the test-server-vshost memory increases, it can go from 70MB to 200MB and i have seen it reach 630MB, but it also hangs when it is around 80-100 or so, no pattern whatsoever.
remuo
 
Posts: 14
Joined: December 29th, 2010, 6:19 pm

Re: VS debugger is crashing

Postby remuo » February 22nd, 2011, 5:33 pm

I put a [STAThread] before the GameStarted method and i think it shows some improvement, not that it doesn't hang anymore but it hangs less often than before.
remuo
 
Posts: 14
Joined: December 29th, 2010, 6:19 pm

Re: VS debugger is crashing

Postby Oliver » February 23rd, 2011, 8:58 pm

Hey Remuo,

Thanks for the detailed reporting.. I don't really know what to do about it, because i can't reproduce it here, so i'm inclined to think that it is something on your machine online causing it.

- Oliver
User avatar
Oliver
.IO
 
Posts: 1159
Joined: January 12th, 2010, 8:29 am


Return to C#



cron