Fez Cobra Freeze - new thread

I’ve noticed some strange behaviour on my Fez Cobra II for a while now but it’s starting to become a big problem.

I’ve been testing some client/server comms software using the built in wifi with the board close to the edge of the wifi range. Naturally, I’m getting quite a few exceptions but this is to be expected and the software has quite a lot of exception handling code.

Occasionly (and getting more frequent) the whole system will just lock-up and freeze. When this happens and I am debugging using VS2012, I find that I am able to perform a ‘Break All’ on the running app and it always seems to be on a line of code that is creating and starting a new thread, similar to:

new Thread(new ThreadStart(SomeMethod)).Start();

If I then continue the running on the app it will carry on as if the freeze didn’t happen. Also, this seems to coincide with an exception that was occurring at the same time (the exception appears in the output windows just as you continue).

Has anyone else noticed that happening? A quick search of the forums suggests that it is not a common problem but I’m not sure how I can stop it from happening.

If it only happens when the Debugger is attached, then it’s aknown problem.
Hitting pause, and run continues execution.
It usually does not happen on very simple projects, but with more threads (and eventually thread sync by events and joins) it starts to happen more often.

GHI asked in an other thread where I reported this issue for a small project to reproduce the issue. But my projects usually get huge very quickly.

So if you have a compact project where you can more or less reliably reproduce the issue you should send it to GHI for further investigation.

I knew it! It’s not just me! I have these locks all the time (on G400, though).

Unfortunately, my project is also rather large. There’s plenty of threads running with locking to protect resources but no thread joining.

It seems to happen in conjunction with exceptions (it may only be socket exceptions). I suppose, if a program was written that constantly started new threads, and constantly raised and captured exceptions at the same time, you might be able to reproduce the problem.

I’m also not convinced that it only happens in the debugger. My app is in a testing stage at the moment and I am writing a log file on the SD card. I swear that I’ve seen it happen without the debugger, but I am testing it and I need to rule out other bugs first.

Well, the SD card performance and reliability is an other topic (specially on G120).
If power goes off when a write operation is not flushed to SD, then you might not be able to write to that folder on the SD card anymore until you delete that folder or format the card.

I’m seeing something like this tonight with a G400D. The programme appears to freeze when debugging. My display stops being updated and the errors I am trying to debug from the I2C stop.

Pressing pause and the code breaks at a Thread.Sleep() line. Pressing CONTINUE and it re-starts the programme for a few more seconds then it freezes again.

It’s very consistent and extremely annoying trying to debug the code when this happens.

When you run it with a debug connection, but the debug cable still connected, it runs fine.