Page 1 of 1

Non reproducable crash with PB 5.6 and later

Posted: Sat Sep 14, 2019 10:54 am
by e-biker
Hi folks,

I have a problem with one of my Windows programs I developed for one of my clients.

It is running 100% stable when compiled with PB 5.46 LTS but will crash randomly after 5 - 30 min in use when compiled with all later versions. Crash means the program window freezes. Sometimes the you can still close the program by the window exit button sometimes you have to you the task manager to kill it. The behavior is the same if you run it in the IDE debugger or as standalone compiled program. OnError or debugger is not triggered at all. The crash can't be reproduced by a certain action in the program.

Can I get information from Windows what caused the crash? Windows 32 and 64 bit show the same behavior.

Since there is a lot of Canvas Gadget event handling involved can it be that the updates to the Canvas Gadget (container) might cause the crashes?

All ideas are welcome!

Erich

Re: Non reproducable crash with PB 5.6 and later

Posted: Sat Sep 14, 2019 11:25 am
by Bisonte
Without code it's hard to say... but 5.46 was the latest Version with ASCII support.
Maybe you use an extern lib that requires ASCII values... maybe you are using threads ?

Many things....

Re: Non reproducable crash with PB 5.6 and later

Posted: Sat Sep 14, 2019 11:41 am
by BarryG
My mistake; it's not a crash situation in the manner I was describing. Pointless tips removed.

Re: Non reproducable crash with PB 5.6 and later

Posted: Sat Sep 14, 2019 11:58 am
by #NULL
The description sounds like it's not a crash at all, but rather a freezing (unresponsive). Maybe there is some event processing done wrong?

Re: Non reproducable crash with PB 5.6 and later

Posted: Sat Sep 14, 2019 3:59 pm
by Bitblazer
First try running it with the purifier enabled and see what happens. Alternatively you can run a tracer. I think the purebasic forum had two of them as tools, but they might be years old. I personally use my own version, but its not ready for release.

If it is a message processing problem, you might just use a bunch of debug commands to find the reason, or something like a windows message debugging tool. The one on my website includes a purebasic source interface to debug message processing from the inside of your application.

If you still dont know what is the cause : make it crash while running it from WinAPIOverride. Then check the bottom log of what happened.

Re: Non reproducable crash with PB 5.6 and later

Posted: Sun Sep 15, 2019 12:28 pm
by #NULL
#NULL wrote:The description sounds like it's not a crash at all, but rather a freezing (unresponsive). Maybe there is some event processing done wrong?
To elaborate on this..
If you react to events by doing things that trigger other events, this could lead to endless (or at least very long) loops. For example with the following code on Linux if you resize the window with the mouse by making it smaller, this will trigger events repeatedly and the window becomes unresponsive, at least for a while.

Code: Select all


win = OpenWindow(#PB_Any, 50,100, 800, 600, "..", #PB_Window_SystemMenu | #PB_Window_SizeGadget)
Repeat
  
  While WaitWindowEvent(10)
    Select Event()
      Case #PB_Event_CloseWindow
        quit = #True
      Case #PB_Event_SizeWindow
        Debug "size event, " + Random(999)
        ResizeWindow(win, #PB_Ignore, #PB_Ignore, 810, #PB_Ignore)
    EndSelect
  Wend
  
  Debug "events done"
  
Until quit

This could also be less obvious than in the example if a chain of multiple different events create a trigger loop.
With the following code all events are processed first and only then are new events triggered:

Code: Select all

win = OpenWindow(#PB_Any, 50,100, 800, 600, "..", #PB_Window_SystemMenu | #PB_Window_SizeGadget)
Repeat
  
  sized = #False
  
  While WaitWindowEvent(10)
    Select Event()
      Case #PB_Event_CloseWindow
        quit = #True
      Case #PB_Event_SizeWindow
        sized = #True
        Debug "size event, " + Random(999)
    EndSelect
  Wend
  
  Debug "events done"
  
  If sized
    ResizeWindow(win, #PB_Ignore, #PB_Ignore, 810, #PB_Ignore)
  EndIf
  
Until quit
This might still trigger events forever, but all event s are processed in between so the window stays responsive. Custom events is another way it could be done but I once had problems due to their different priority.

Re: Non reproducable crash with PB 5.6 and later

Posted: Sun Sep 15, 2019 1:30 pm
by skywalk
Yes, for cases like this, would a log file and healthy delay()'s,10-100ms help?
If the log file is blocking, that slows down the rat race.

Re: Non reproducable crash with PB 5.6 and later

Posted: Tue Sep 17, 2019 12:22 pm
by e-biker
Thank you all!

Your comments are great and now I think so too, that the error is an unresponsive freezing.
I have the admit that the error occurred now once also with PB 5.46 LTS, so my assumption and the topic of this thread is not correct.
I will have to scrutinize the event handling and try to separate the different events in the loop.

You all really helped me a lot!

Erich