Question Find Where Code Stops

stulish

Well-known member
Joined
Jun 6, 2013
Messages
61
Programming Experience
3-5
hi all,

I have been working on a project for a few months now and recently i have been having a problem where the program just stops, windows doesn't report it as not responding and the resources used by the program are at normal levels (it isn't increasing).

The program basically records data from many bits of hardware over serial connection, video capture and audio capture, then zips the files in 1 minute chunks and saves them in 3 locations.

The program has run for between 6 and 20 hours before this error (or what ever it is) causes it to stop, with no error is thrown in VB.NET, it is as if it is stuck in a loop, the UI thread is completely unresponsive. I have created multiple DLLs to handle different aspects of the program:

Video DLL: captures a video screen shot every 15 seconds from upto 6 sources (user cnfigurable), and saves them as JPG.
Audio DLL: capture audio from up to 10 sources at a speed of 22khz and saves as individual mono WAV files.
Serial DLL: captures all Serial Data input and records to a TXT file.
File DLL: this basically compresses all the recorded images every 60 seconds and saves them to the back-up locations.

I have found when it crashes the Audio DLL keeps producing the Audio files, but everything else stops.

Does anyone have any tips how to find out where the program is if it is stuck in a loop, or something similar. This wouldn't be such a bad problem bu if i have to wait upto 20 hours for it to occur finding the problem could take a while.


Thanks

Stu
 
I think you'll have to add some tracing code, i.e. have the application output to a file or the like some information about where it's up to. When it fails, you will know that it was somewhere between the last output written and the point at which the next output was expected. If necessary, you can refine the tracing code to just that section and use smaller chunks. Eventually you'll be able to narrow it down to the smallest chunk possible and, if required, you can dump the whole app state at that point to find out what's going on.
 
Thanks, i was wondering if i needed to do something like this or if there was something built in, oh well time to get creative :)

Is there a procedure for dumping the whole app state, this could be useful now and in the future.

Cheers

Stu
 
Thanks, i was wondering if i needed to do something like this or if there was something built in, oh well time to get creative :)
It is built in to a degree. Check out the TraceListener class.
Is there a procedure for dumping the whole app state, this could be useful now and in the future.
You might be able to do a simple memory dump but I'm not sure that that would be useful anyway. Other than that it would be a manual process.
 
Thanks again,

I have created a small sub to log where the program is:

ErrLogger(New StackTrace(New StackFrame(True)).GetFrame(0).GetFileLineNumber)

the ErrLogger code just writes the value in brackets to a text file so i see what line number it is at, i just call it at the start of each sub, hopefully i will find out what sub was called last and go from there.


 
I just looked at the TraceListener and it looks alot better than what i have done so, back in and implement this class.

Thanks

Again, I will let you know what i find :)
 
After using trace listener, and letting it crash a couple of times it always stopped at the same point, i found it was the serial port out, when i tried to write to the serial port it timed out for some reason (this seems to take a few hours to happen), so i set the write timeout to 200ms and it runs fine now.

Still not sure why it would time out as i am not using any handshaking, it should just transmit and forget, and not wait for a response. I will look in to this and if it remains a problem, i think i may have to close the port and then re-open to clear it all down (even through the read and write buffers remain at 16 bytes or less).

Thanks again for your help
 

Latest posts

Back
Top