Fix restoration of loop target in try statement #323
No reviewers
Labels
No Milestone
No Assignees
2 Participants
Notifications
Due Date
No due date set.
Depends on
#324 Meta changes from #301
M-Labs/nac3
#325 Meta Changes from #321
M-Labs/nac3
Reference: M-Labs/nac3#323
Loading…
Reference in New Issue
No description provided.
Delete Branch "issue-301"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
CFG of
old_loop_target
:old_loop_target
stores the previous value ofctx.loop_target
only ifhas_cleanup && ctx.loop_target.is_some()
. Therefore,ctx.loop_target
should restore fromold_loop_target
only ifctx.loop_target
was overwritten, which is indicated byold_loop_target.is_some()
.Fixes #301.
49660c4e6f
toe07cc64a95
v2: Rebased against
meta-changes-for-issue-301
@ -790,3 +790,3 @@
ctx.unwind_target = old_unwind;
ctx.return_target = old_return;
ctx.loop_target = old_loop_target;
if let Some(old_loop_target) = old_loop_target {
Should be marked as workaround in the code comments and corresponding Issue opened, as discussed.
e07cc64a95
toe97ceb0da9
v3: Updated fix which better addresses the problem. Description of the Pull Request is also updated.
@ -0,0 +1,114 @@
#include <assert.h>
Should not be in this PR either.
@ -24,6 +24,7 @@ use nac3parser::{
use parking_lot::RwLock;
use std::collections::{HashMap, HashSet};
use std::sync::Arc;
use inkwell::targets::{InitializationConfig, Target};
Should this be here?
e97ceb0da9
to48c6498d1f
v4: Rebased onto
meta-changes-from-issue-301
.Why was it broken before? I don't understand what was going on with the Option.
@ -98,2 +98,4 @@
}
#[no_mangle]
pub extern "C" fn __nac3_end_catch() {}
Does this belong in this PR?
Yes, this is necessary for
loop_try_break
to link, possibly due to the use of thecatch
block.old_loop_target
is only assigned ifhas_cleanup
istrue
, otherwise it would beNone
. Later when the loop target needs to be restored, it is never checked whetherold_loop_target
is assigned or ifhas_cleanup
istrue
, meaning that for cases wherehas_cleanup
is false,
Nonewill be unconditionally restored to
ctx.loop_target`, causing the original loop target to be lost forever.