Click here to Skip to main content
15,887,676 members
Please Sign up or sign in to vote.
5.00/5 (1 vote)
See more:
Ok, I have a problem, and I'm not expecting an answer straight off. I need some help, bouncing ideas if anyone can spare the time. I find that talking about things like this can help come to a solution quicker, but I'm stuck for someone to talk to about it!

I have a .Net 2.0 Winforms program that runs on people's computers. It appears as a small Form, for instance, in the bottom right of their monitor, guiding them on what to do next in a sort of assessment type way. It is running constantly, monitoring their keystrokes and mouse clicks. It then compares what they have just done to a set of things that they have to do and if they do it right, then they get a score for that particular step and the program moves on to the next step to compare what you are doing.

Everything works fine for many many people. However, for one company that use it, the program freezes.

I have put in some debug logging to a text file, so that I can see what functions are being called and when, any exceptions that might be occurring. This doesn't have any pattern to it when the freeze occurrs.
I've checked Windows Event Logs, that just tells me the program froze. I've checked what programs they have running in the background and the resources that are available on the computer whilst it's running.

I've tried replicating on my machine and I can't.

OK, so obviously you're reading this and thinking, how the hell can I help? Well, tell me what you might look for or how you might approach it. There's way too much code to post here, as I can't pinpoint a specific area. There might be a tool that could be run on their computer for instance, they wouldn't mind me doing that from a remote session.

There are multiple threads occurring, and Mutexes being used along the way. It's possible that one is being locked and not released. I've updated the code to try and make sure this doesn't happen already.

I appreciate this is not a 'How do I order date times in a DataGridView' type question but any ideas would be most appreciated.

Julian

What I have tried:

Detailed debug log to text file
Checked Windows Event Logs
Updated code in possible problem area
Checked background resources + antivirus logs - to no avail
Posted
Updated 15-Sep-20 23:39pm
Comments
Kornfeld Eliyahu Peter 10-Aug-17 11:14am    
Do you have some reasons in the Even Log for the freeze?
Do you have only one instance of your application?
How many mutexes do you have?
jugs0101 10-Aug-17 11:23am    
Hi Kornfeld,

Thanks for responding! In answer to your questions:

1. There is no indication in my own event log (to file) or the Windows Event Log as to the freeze. Windows just indicates that the program has frozen (I don't have the exact text in front of me I'm afraid).

2. Yes, there is only ever one instance of the program running. I have confirmed this by actually watching the client repeat the problem over a GoTo meeting.

3. I believe that there are 2 separate instances of mutexs occurring, being locked and released at various stages.

Of note, I didn't write the code originally and the developer that did is no longer at the company.

Cheers.
Kornfeld Eliyahu Peter 10-Aug-17 11:46am    
I remember a problem in my C++ day (didn't used mutex in .NET), that we solved it by locking the mutex instances always by the same order, otherwise it can be lead to an interlock...
It is possible that your threads are starting in alternating orders and for that the locking appears in different orders, so some of them will not released correctly and the next time the thread kicks in it can not acquire a lock and froze...
jugs0101 10-Aug-17 12:08pm    
Thanks Kornfeld.

I think I will draw out exactly what threads are being created and where, how long they run for (it looks like 3 thread IDs are being used during the call to the Mutex, so they are in loops througout the duration, if you get my drift).

I will then see if I can spot any obvious way in which one lock may happen and cause another to freeze.

It it your understanding that a mutex lock is only locked on a particular thread?

Julian
Kornfeld Eliyahu Peter 10-Aug-17 12:11pm    
Log also the request for lock with the mutex name...
As much as I can remember locking mutex on secondary thread (and not on the main) can lead exactly to what you see...

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