Skip to content
This repository was archived by the owner on Nov 4, 2023. It is now read-only.

Try/Catch leaves the stack (locals) in an invalid state after a Throw under certain conditions. #13

@ghost

Description

Im not sure what exactly causes this, but it seems that some local variables that are optimized away does not end up in the exception frame.
Unless those locals are used ABOVE the try, like getting its address, they will have an invalid state (the one prior to entering Try) when re-entering the scope after a Throw.

minified sample:

Framework BRL.StandardIO

SuperStrict

Function Bail()
	Throw "BAIL"
EndFunction

Function TryFail()
	Local x:Int = 10
	Try
		x :* 2
		Bail()
	Catch e:Object
		Print e.ToString() + "   x == " + x + "  should be 20"
	EndTry
EndFunction

Function TryOk()
	Local x:Int = 10
	Local p:Byte Ptr = Varptr x ' taking the address solidifies the variable
	Try
		x :* 2
		Bail()
	Catch e:Object
		Print e.ToString() + "   x == " + x + "  should be 20"
	EndTry
EndFunction

TryFail()
TryOk()

output (win32):

BAIL   x == 10  should be 20
BAIL   x == 20  should be 20

expected output:

BAIL   x == 20  should be 20
BAIL   x == 20  should be 20

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions