Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

try fails to catch alarm #3371

Open
pzinn opened this issue Jul 21, 2024 · 4 comments
Open

try fails to catch alarm #3371

pzinn opened this issue Jul 21, 2024 · 4 comments

Comments

@pzinn
Copy link
Contributor

pzinn commented Jul 21, 2024

There are already existing open issues with alarm, this I think is a new one:

i1 : try (alarm 1; sleep 15;) else <<"should end up here (and does)"<<endl;
should end up here (and does)

i2 : try (alarm 1; sleep 15) else <<"should end up here (and doesn't)"<<endl;
stdio:2:51:(3): error: alarm occurred

This issue is presumably related to tail call optimisation (?).
Note that I already submitted a PR a while ago about tail call, namely #3144, but it does not impact the issue described above.

I traced the issue to two different places that alarm is triggered, both in evaluate.d, namely evalraw in the first case, evalexcept in the second. I could try to fix something but first I would need to understand better the difference between these two functions. Note that evalraw has this comment

	  if test(exceptionFlag) && !steppingFurther(c) then (    -- compare this code to the code in evalexcept() below

presumably suggesting I should notice something that I don't...

@mahrud
Copy link
Member

mahrud commented Jul 21, 2024

To make sure I understand, the problem is that try isn't catching the errors occurred during TCO, right? e.g. things look fine without try:

i27 : f = t -> (alarm 1; sleep t;); f 10
stdio:23:38:(3): error: alarm occurred

i29 : f = t -> (alarm 1; sleep t); f 10
stdio:24:37:(3): error: alarm occurred

I'm sure you've seen it, but the solution might be related to #2596 also.

@pzinn
Copy link
Contributor Author

pzinn commented Jul 22, 2024

I don't think this is the same bug as #2596, though experience fixing one might help with the other.

@pzinn
Copy link
Contributor Author

pzinn commented Jul 22, 2024

@DanGrayson (or anyone else) can you explain why eval(f:Frame,c:Code) calls evalexcept:

M2/M2/Macaulay2/d/evaluate.d

Lines 1616 to 1621 in ec9e9ac

export eval(f:Frame,c:Code):Expr := (
saveLocalFrame := localFrame;
localFrame = f;
ret := evalexcept(c);
localFrame = saveLocalFrame;
ret);

and not just eval(c:Code)? I guess I'm asking the same question as above, what is the purpose of evalexcept?

@pzinn
Copy link
Contributor Author

pzinn commented Oct 30, 2024

considering #3144 has been reverted, this can hopefully be fixed at the same time as the issue #3546 underlying the latter.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants