The debugging executable closes unexpectedly, what should I do?

Just starting out? Need help? Post your questions and find answers here.
Boulcat
User
User
Posts: 28
Joined: Fri Feb 28, 2020 11:51 am

The debugging executable closes unexpectedly, what should I do?

Post 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) ?
User avatar
jacdelad
Addict
Addict
Posts: 1487
Joined: Wed Feb 03, 2021 12:46 pm
Location: Planet Riesa
Contact:

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

Post 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.
...
PureBasic 6.04/XProfan X4a/Embarcadero RAD Studio 11/Perl 5.2/Python 3.10
Windows 11/Ryzen 5800X/32GB RAM/Radeon 7770 OC/3TB SSD/11TB HDD
Synology DS1821+/36GB RAM/130TB
Synology DS920+/20GB RAM/54TB
Synology DS916+ii/8GB RAM/12TB
User avatar
spikey
Enthusiast
Enthusiast
Posts: 594
Joined: Wed Sep 22, 2010 1:17 pm
Location: United Kingdom

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

Post by spikey »

...
Switch on Preferences → Debugger → Stop execution at program start, that way you can begin stepping right from the beginning.
Boulcat
User
User
Posts: 28
Joined: Fri Feb 28, 2020 11:51 am

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

Post 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!
User avatar
skywalk
Addict
Addict
Posts: 4003
Joined: Wed Dec 23, 2009 10:14 pm
Location: Boston, MA

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

Post 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.
The nice thing about standards is there are so many to choose from. ~ Andrew Tanenbaum
Boulcat
User
User
Posts: 28
Joined: Fri Feb 28, 2020 11:51 am

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

Post 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.
BarryG
Addict
Addict
Posts: 3330
Joined: Thu Apr 18, 2019 8:17 am

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

Post 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.
Olli
Addict
Addict
Posts: 1071
Joined: Wed May 27, 2020 12:26 pm

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

Post 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.
Boulcat
User
User
Posts: 28
Joined: Fri Feb 28, 2020 11:51 am

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

Post 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?
User avatar
jacdelad
Addict
Addict
Posts: 1487
Joined: Wed Feb 03, 2021 12:46 pm
Location: Planet Riesa
Contact:

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

Post 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.
PureBasic 6.04/XProfan X4a/Embarcadero RAD Studio 11/Perl 5.2/Python 3.10
Windows 11/Ryzen 5800X/32GB RAM/Radeon 7770 OC/3TB SSD/11TB HDD
Synology DS1821+/36GB RAM/130TB
Synology DS920+/20GB RAM/54TB
Synology DS916+ii/8GB RAM/12TB
BarryG
Addict
Addict
Posts: 3330
Joined: Thu Apr 18, 2019 8:17 am

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

Post 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
User avatar
spikey
Enthusiast
Enthusiast
Posts: 594
Joined: Wed Sep 22, 2010 1:17 pm
Location: United Kingdom

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

Post 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.
User avatar
jacdelad
Addict
Addict
Posts: 1487
Joined: Wed Feb 03, 2021 12:46 pm
Location: Planet Riesa
Contact:

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

Post by jacdelad »

Yeah sure, I can insert that by myself. I mean an auto detection.
PureBasic 6.04/XProfan X4a/Embarcadero RAD Studio 11/Perl 5.2/Python 3.10
Windows 11/Ryzen 5800X/32GB RAM/Radeon 7770 OC/3TB SSD/11TB HDD
Synology DS1821+/36GB RAM/130TB
Synology DS920+/20GB RAM/54TB
Synology DS916+ii/8GB RAM/12TB
BarryG
Addict
Addict
Posts: 3330
Joined: Thu Apr 18, 2019 8:17 am

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

Post by BarryG »

Posted it for the benefit of the new-comers here, who would likely not be aware.
Post Reply