Skip to content

Commit bc646d0

Browse files
committed
Fix leaking arg slots on tail calls. Closes #160.
1 parent 67aa39e commit bc646d0

File tree

3 files changed

+14
-0
lines changed

3 files changed

+14
-0
lines changed

src/Makefile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -533,6 +533,7 @@ TEST_XFAILS_LLVM := $(TASK_XFAILS) \
533533
str-concat.rs \
534534
str-idx.rs \
535535
tag.rs \
536+
tail-call-arg-leak.rs \
536537
tail-cps.rs \
537538
tail-direct.rs \
538539
task-comm.rs \

src/boot/me/trans.ml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4219,6 +4219,8 @@ let trans_visitor
42194219
(Printf.sprintf "copy args for tail call to %s" (logname ())));
42204220
copy_fn_args true true CLONE_none call;
42214221
drop_slots_at_curr_stmt();
4222+
iflog (fun _ -> annotate "drop args");
4223+
iter_arg_slots cx (current_fn()) callee_drop_slot;
42224224
abi.Abi.abi_emit_fn_tail_call (emitter())
42234225
(force_sz (current_fn_callsz()))
42244226
caller_argsz callee_code callee_argsz;
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
// use of tail calls causes arg slot leaks, issue #160.
2+
3+
fn inner(str dummy, bool b) {
4+
if (b) {
5+
be inner(dummy, false);
6+
}
7+
}
8+
9+
fn main() {
10+
inner("hi", true);
11+
}

0 commit comments

Comments
 (0)