Page 1 of 1

The debugging executable closes unexpectedly, what should I do?

Posted: Tue Nov 28, 2023 12:39 pm
by Boulcat
I must have a bug, I've had it before but I don't know how to reproduce it.
And just now I've got again the error: "PureBasic Debugger - the debugging executable closes unexpectedly".
I haven't closed it yet but I can't access the debugging tools. What can I do to get more information (procedure in error, stack entry) ?

Re: The debugging executable closes unexpectedly, what should I do?

Posted: Tue Nov 28, 2023 12:41 pm
by jacdelad
Hi,
this error message means that you program crashed. You can either shrink it to the point that it doesn't crash and compare it with last shrunk version that crashed or split it into pieces, if possible, and test them separately.
If you have a small code with the crash behaviour, you can also post it here and we will find the problem.

Once the debugger crashed you cannot access its information anymore (because it crashed).

More things you can do:
Put message requester or debug outputs here and there and check which one was last shown/put out.
Use debugger breakpoints.
Set the purifier to super sensitive.
...

Re: The debugging executable closes unexpectedly, what should I do?

Posted: Tue Nov 28, 2023 1:08 pm
by spikey
...
Switch on Preferences → Debugger → Stop execution at program start, that way you can begin stepping right from the beginning.

Re: The debugging executable closes unexpectedly, what should I do?

Posted: Tue Nov 28, 2023 3:31 pm
by Boulcat
Thanks for the info, I'll try your suggestions.
I can't share a piece of code because I have no idea where it crashes in my 20,000 lines of code. I'd like to have some kind of explanation, so that I can reduce it while keeping the bug.
The problem is that I don't even know what manipulation to do to reproduce it. It must be in a special case.
Is there a difference between putting a breakpoint at the beginning and "Stop execution at program start" debugger option ?
I'll try to add some debug outputs, I hope the debug window will remain open for the next crash!

Re: The debugging executable closes unexpectedly, what should I do?

Posted: Tue Nov 28, 2023 4:02 pm
by skywalk
You can also make a log file. Just append to it wherever you would place a debug statement.
Things like; Program start-time, versions of included libs, addresses of dll functions to verify non-zero, ip addr, etc.

Re: The debugging executable closes unexpectedly, what should I do?

Posted: Tue Nov 28, 2023 6:19 pm
by Boulcat
Yes, I've started to write the debug output, but as I don't know if the debug window will remain open during the next crash, it's probably better to have a log file for each test in %temp%. I cross my fingers to put enough info to understand.
With the debug output, I've already seen a small operating error, unrelated to the crash.

Re: The debugging executable closes unexpectedly, what should I do?

Posted: Tue Nov 28, 2023 10:00 pm
by BarryG
Does your app use threads, and if so, is "Thread safe" enabled in the Compiler Options? I've been stung by that before.

Re: The debugging executable closes unexpectedly, what should I do?

Posted: Wed Nov 29, 2023 12:02 am
by Olli
A very old time before, a crash had the following effects :
- often, black screen, sometime, strange display
- no save done
- RESET button might be pushed

The result of these events did a natural selection : everything which has crashed, is forever lost. So, the crashes disappear step by step.

So, if I remember, when it crashed like this (described more above), it was an external problem, or an external library.

Cut you source code in two equal parts. (dichotomy) And cut the bad part in two equal parts, etc...
22000 lines < 2^15 lines
So, after 15 steps, you find the problem.

Re: The debugging executable closes unexpectedly, what should I do?

Posted: Wed Nov 29, 2023 11:16 am
by Boulcat
I don't have a thread. I've just read the help and noted that it's better to enable the compile option as soon as you use a thread, I'll try to remember.

Reducing a source by dichotomy can't be really easy, procedures call each other.
In my case, anyway, I can't use it because I wouldn't even know if the cut pieces were good or not.
At the moment it works most of the time, but once in a while it crashes without understanding the manipulation that causes it.

I think I'll stick with the log idea for now,
For the moment, I'm writing a line for each procedure entry, with some appropriate parameters.
Is there a limit size for log files to check ?

I don't know enough! Wouldn't it be possible, in debug, to have an additional option, that allows us to trace procedure calls (outside the exe) and that you can look at afterwards, whether or not a crash has occurred?

Re: The debugging executable closes unexpectedly, what should I do?

Posted: Wed Nov 29, 2023 11:24 am
by jacdelad
Would be cool if the compiler threw a warning when using a thread related function without ThreadSafe. This wouldn't solve all problems, but maybe a few.

Re: The debugging executable closes unexpectedly, what should I do?

Posted: Wed Nov 29, 2023 11:39 am
by BarryG
jacdelad wrote: Wed Nov 29, 2023 11:24 amWould be cool if the compiler threw a warning when using a thread related function without ThreadSafe.
At the start of my app:

Code: Select all

CompilerIf #PB_Compiler_Thread=0
  MessageRequester("Compile Error","Thread-safety is not enabled!",#PB_MessageRequester_Error)
  End
CompilerEndIf

Re: The debugging executable closes unexpectedly, what should I do?

Posted: Wed Nov 29, 2023 11:50 am
by spikey
jacdelad wrote: Wed Nov 29, 2023 11:24 am Would be cool if the compiler threw a warning when using a thread related function without ThreadSafe.

Code: Select all

CompilerIf #PB_Compiler_Thread = 0
  CompilerError "Fatal: Compiler option 'Create threadsafe executable' must be on."
CompilerEndIf
Or there's CompilerWarning if you prefer it not to halt the compilation.

Re: The debugging executable closes unexpectedly, what should I do?

Posted: Wed Nov 29, 2023 11:57 am
by jacdelad
Yeah sure, I can insert that by myself. I mean an auto detection.

Re: The debugging executable closes unexpectedly, what should I do?

Posted: Wed Nov 29, 2023 10:14 pm
by BarryG
Posted it for the benefit of the new-comers here, who would likely not be aware.