General debugger and threads question

Previous topic - Next topic


I have made a few major changes to a project im working on and am now experiencing random crashes.

If I have debug on then the code seems to crash at random places anywhere between 10 and 30 seconds after starting up. According to the debugger its still running as I can pause it and step through each line.

If debug is off then it seems to be fine until I remove focus from the program and then it locks up and even clicking back on the app does not restore it running (I have AUTOPAUSE FALSE at the top of the program)

Also when running in debug in the thread that is running I have put in a debug message that is displayed every loop, this also stops making me think the thread is the part of the program that has hung (all of my graphic updates and button detection is done in the thread so this would give the impression of the main program locking up.

Has anyone else noticed anything similar when using threads recently? Or if not is there any way I can debug the thread that is running with the debugger?



Just run a few more tests and it is the thread locking out or getting stuck in a loop somewhere. So can the debugger be forced to run the code in the thread rather than the main program?


I had a complete lockup when a ShowScreen wasn't being done and the loop was then obviously CPU overhaul.. Curious if something similar is happening. |

Comps Owned - ZX.81, ZX.48K, ZX.128K+2, Vic20, C64, Atari-ST, A500.600.1200, PC, Apple Mini-Mac.


Its actually a very strange bug. as I want to run the thread approximately every 20ms I do something like this

Code (glbasic) Select

. thread code in here
DEBUG "sleeptime = "+sleeptime+"\n"
SLEEP sleeptime // have a little rest for now

Now most of the time sleeptime is returning 14-16 ms but when it locks up it has returned a negative number. It can lock out when the focus is on the window or when its off it. Nothing is trashing threadstart, its almost like GETTIMERALL() is returning a false value


Are you actually creating a new thread, or are just talking about a block of code ?

The debugger will appear to freeze if there is no SHOWSCREEN as that releases control back to the operating system.  Fraps can also cause a problem and of course infinite loops...

Its possible SLEEP is not returning control back to the debugger...


found it

Of course if the thread takes more than 20ms to run then you end up with

20-(number larger than 20)

Which gives a negative sleep value and the thread halts

Thanks for the tips anyway