perl5
perl5 copied to clipboard
Add `PL_throwing`, true during exceptional stack unwind
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}
Shouldn't PL_throwing be true when we unwind due to an exception whether or not we are inside of an eval?
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.
More tests added; @demerphq PTAL
@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?
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 Much thanks :) I'll take a look again and see what the next steps ought to be
This is conflicting over the perldelta. I guess there isnt much point in fixing it until tomorrow.
@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.