Forum > Windows

Program crashes on Windows 11 within Try Except

(1/5) > >>

gicla:
Hi everybody,

After days trying to understand I decided to post here as I'm lost.
My program always ran fine on Windows10. Since a few months I upgraded to Windows 11 and now at all the Try...Except, in cas of errors it freezes instead of executing the Except clause.
Any hint please?

That's the code which hangs:

--- Code: Pascal  [+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i < x.length; i++) { x[i].style.maxHeight='none'; x[i].style.height = Math.min(x[i].clientHeight+15,306)+'px'; x[i].style.resize = "vertical";}};} ---  // Verify Fields value type for M fields and MF or MD whitin approved messages        case UpperCase(copy(aFieldsDef[3, z], 1, 3)) of          'INT' : begin                    try                      iTestValue := StrToInt64(AnsiString(xmlDoc.DocumentElement.FindNode(aFieldsDef[1, z]).TextContent));                    except                      WriteError('Line: ' + sLine + ' | ' + xmlStr.DataString, 'ERROR: "' + AnsiString(aFieldsDef[1, z]) + '" value MUST be numeric, only digits allowed here.');                    end;                  end;          'STR' : begin                   end;          'CON' : begin     { TODO : da eliminare e gestire }                   end;          else MessageDlg('(' + AnsiString(sMsgType) + ') ' + AnsiString(aFieldsDef[1, z]) + ' - Wrong field type definition ' + '(' + UpperCase(copy(aFieldsDef[3, z],1,3)) + ')' + ' into the ini file.' + #10 + 'Allowed values are:' + #10 + '"STR" = String' + #10 + '"INT" = Numeric', mtWarning, [mbOK], 0);        end; 
I tried to inser the following test code in teh same procedure which hangs and it also hangs:

--- Code: Pascal  [+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i < x.length; i++) { x[i].style.maxHeight='none'; x[i].style.height = Math.min(x[i].clientHeight+15,306)+'px'; x[i].style.resize = "vertical";}};} ---  divider := '0';  Try    Result := 5 div StrToInt(divider);  Except    showmessage('0 divide not possible');  end;  
However, the same sample code used in a different procedure, works just fine.

rvk:
So what does WriteError do?

What happens if there is an exception in your except clause?

What happens after this code?

Just change the writeerror to

--- Code: Pascal  [+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i < x.length; i++) { x[i].style.maxHeight='none'; x[i].style.height = Math.min(x[i].clientHeight+15,306)+'px'; x[i].style.resize = "vertical";}};} ---on E: exception do showmessage(e.message);and you'll see the actual reason for the exception.
(Or run in the IDE and let it catch the exception)

Thaddy:
Note EDivideByZero is one of the standard exceptions defined in sysutils.ou do noy want to rely on sysutils, because of its size, you can check for error 200.

PascalDragon:

--- Quote from: Thaddy on December 10, 2023, 06:52:08 pm ---Note EDivideByZero is one of the standard exceptions defined in sysutils.ou do noy want to rely on sysutils, because of its size, you can check for error 200.

--- End 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.

Bart:

--- Quote from: PascalDragon on December 10, 2023, 09:18:19 pm ---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.

--- End quote ---
Is that documented somewhere?

Bart

Navigation

[0] Message Index

[#] Next page

Go to full version