perl5 icon indicating copy to clipboard operation
perl5 copied to clipboard

Add `PL_throwing`, true during exceptional stack unwind

Open leonerd opened this issue 3 years ago • 8 comments

This PR adds a mechanism by which code that runs during stack unwind (finally and defer blocks at the Perl layer, SAVEDESTRUCTOR* at the XS layer) can inspect whether that stack unwind is happening because of a thrown exception. Or, at least, whether a stack unwind because of a thrown exception is happening - not necessarily "this" one.

Such a mechanism is a prerequisite to solving #20389, and also hinted at by the comment https://github.com/Perl/perl5/blob/1932805f63d6181a90fe36fabbdc3755a78b072f/pp_ctl.c#L1776-L1782

Still undecided:

  • How it should behave during nested (normal) unwinds invoked as part of an exceptional one
  • Whether a pure-perl wrapping should be added; perhaps by a interpreter-global variable ${^THROWING}

leonerd avatar Oct 17 '22 16:10 leonerd

Shouldn't PL_throwing be true when we unwind due to an exception whether or not we are inside of an eval?

demerphq avatar Oct 18 '22 12:10 demerphq

Shouldn't PL_throwing be true when we unwind due to an exception whether or not we are inside of an eval?

Ah, yes it should. I'll move the assignment further out.

leonerd avatar Oct 18 '22 16:10 leonerd

More tests added; @demerphq PTAL

leonerd avatar Oct 19 '22 15:10 leonerd

@leonerd i know this is a draft, but it conflicts and seems stalled. Do you have plans to pick this up again? Can we at least get it updated to latest blead?

demerphq avatar Feb 07 '23 14:02 demerphq

Since some of the conflicts where from my embed related patches I took the liberty of rebasing and resolving the conflicts to save you the hassle @leonerd. I didn't change anything else.

demerphq avatar Feb 08 '23 10:02 demerphq

@demerphq Much thanks :) I'll take a look again and see what the next steps ought to be

leonerd avatar Feb 08 '23 12:02 leonerd

This is conflicting over the perldelta. I guess there isnt much point in fixing it until tomorrow.

demerphq avatar Feb 20 '23 14:02 demerphq

@leonerd there has been no discussion in this draft p.r. in a year-and-a-half, and the code has re-acquired merge conflicts. Do you still plan to pursue it? Thanks.

jkeenan avatar Aug 27 '24 20:08 jkeenan