Recent

Author Topic: Program crashes on Windows 11 within Try Except  (Read 4478 times)

PascalDragon

  • Hero Member
  • *****
  • Posts: 5796
  • Compiler Developer
Re: Program crashes on Windows 11 within Try Except
« Reply #15 on: December 19, 2023, 10:27:20 pm »
.....
It means that it will compile, but an except-block might not be entered correctly if at all if an exception occurs.
Like I said, Wow.
So, quick grep through my code, only 36 "except on", less than I'd expect. But quite a variety.  Is there any point in testing ?  I mean, if I simulate, say an EXMLReadError and its correctly handled, can I assume it would always be correctly handled ?

As soon as you have any descendant of the Exception class you don't need to worry anymore, because that will mean that the SysUtils unit will be used and thus everything will be set up correctly. The problem only occurs if the SysUtils unit isn't used anywhere in your whole program.

dbannon

  • Hero Member
  • *****
  • Posts: 3183
    • tomboy-ng, a rewrite of the classic Tomboy
Re: Program crashes on Windows 11 within Try Except
« Reply #16 on: December 20, 2023, 12:08:33 am »
OK, thanks for that PD, that is a great relief, I always use SysUtils.

As Bart asked, is this documented somewhere ?  Somewhere where the unwary might find it ?  It does sound like a real corner case but could cause someone a lot of trouble if they did replicate the conditions.

Davo
Lazarus 3, Linux (and reluctantly Win10/11, OSX Monterey)
My Project - https://github.com/tomboy-notes/tomboy-ng and my github - https://github.com/davidbannon

Thaddy

  • Hero Member
  • *****
  • Posts: 16318
  • Censorship about opinions does not belong here.
Re: Program crashes on Windows 11 within Try Except
« Reply #17 on: December 20, 2023, 04:24:49 pm »
Yes this is documented all over the official documentation so I wonder how you could have missed it.

Is this a case again of ask before you read? You should know better. This question does not belong here because it is wasting time from other people.  >:D
« Last Edit: December 20, 2023, 04:26:51 pm by Thaddy »
If I smell bad code it usually is bad code and that includes my own code.

dbannon

  • Hero Member
  • *****
  • Posts: 3183
    • tomboy-ng, a rewrite of the classic Tomboy
Re: Program crashes on Windows 11 within Try Except
« Reply #18 on: December 21, 2023, 12:01:56 am »
Yes this is documented all over the official documentation so I wonder how you could have missed it.
Oh, thats good then. Or is it ?

Just to be sure, if Its "all over the official documentation" I suppose its really easy to find. I read through chapter 17 of the Ref, no mention of an unexpected behavior when using Windows to handle an Exception without SysUtils. That seems strange given its "All over".  I also looked in the Wiki and the Help offered when you press F1 in Lazarus. That last Help provided the closest I could find to what we are talking about here Thaddy -

While it is possible to raise an exception with any class descending from TObject, it is recommended to use Exception as the basis of exception class objects: the Exception class introduces properties to associate a message and a help context with the exception being raised. What is more, the SysUtils unit sets the necessary hooks to catch and display unhandled exceptions: in such cases, the message displayed to the end user, will be the message stored in the exception class.

But it does not mention a MSWindow specific problem, does not mention SEH and the fact that its "not supported anymore"

Quote
Is this a case again of ask before you read? You should know better. This question does not belong here because it is wasting time from other people.

No, its usual case of Thaddy sounding authoritative but being careful to not actually help at all.

Here, I will show you how it is done -

See how easy it is to include a link to something your correspondent clearly does not know about ? Give it a try some time.

I have added some text to the Wiki page, but at this stage, I see no reason to believe that the problem Pascal Dragon alerted us to is well documented in the official documentation, I quote -
Quote
On Windows with SEH using try … except-blocks without using the SysUtils unit is currently (from 3.2.0 on) not fully supported anymore, because the SEH implementation is missing some functions to allow the usage without that unit.

Davo
Lazarus 3, Linux (and reluctantly Win10/11, OSX Monterey)
My Project - https://github.com/tomboy-notes/tomboy-ng and my github - https://github.com/davidbannon

Bart

  • Hero Member
  • *****
  • Posts: 5496
    • Bart en Mariska's Webstek
Re: Program crashes on Windows 11 within Try Except
« Reply #19 on: December 21, 2023, 12:48:58 pm »
I have added some text to the Wiki page, but at this stage, I see no reason to believe that the problem Pascal Dragon alerted us to is well documented in the official documentation, I quote -
Quote
On Windows with SEH using try … except-blocks without using the SysUtils unit is currently (from 3.2.0 on) not fully supported anymore, because the SEH implementation is missing some functions to allow the usage without that unit.

And he goes on to say (when I asked wether this was documented):
No, because it's essentially a bug.

Bart

PascalDragon

  • Hero Member
  • *****
  • Posts: 5796
  • Compiler Developer
Re: Program crashes on Windows 11 within Try Except
« Reply #20 on: December 21, 2023, 10:10:27 pm »
I have added some text to the Wiki page, but at this stage, I see no reason to believe that the problem Pascal Dragon alerted us to is well documented in the official documentation, I quote -
Quote
On Windows with SEH using try … except-blocks without using the SysUtils unit is currently (from 3.2.0 on) not fully supported anymore, because the SEH implementation is missing some functions to allow the usage without that unit.

Because it's supposed to work. That it doesn't is a bug. Bugs are not going to be documented as part of the official documentation.

dbannon

  • Hero Member
  • *****
  • Posts: 3183
    • tomboy-ng, a rewrite of the classic Tomboy
Re: Program crashes on Windows 11 within Try Except
« Reply #21 on: December 22, 2023, 04:49:42 am »
Yes, PascalDragon, I see the argument, if its documented in the official documentation, its like saying its a behavior you can depend on, it will stay like that. And that is clearly wrong.

I will annotate the entry I put in the wiki to point out it is a bug and will, at some point in time be fixed at some level.

For most users, those who 'use sysutils' it is a not a problem anyway, adding SysUtils will not adversely affect too many apps in my opinion.

Davo

Lazarus 3, Linux (and reluctantly Win10/11, OSX Monterey)
My Project - https://github.com/tomboy-notes/tomboy-ng and my github - https://github.com/davidbannon

 

TinyPortal © 2005-2018