Skip to content

Commit

Permalink
op/array.t: skip \$#{[]} test under PERL_RC_STACK
Browse files Browse the repository at this point in the history
PERL_RC_STACK builds fixes a bug whereby the [] was being prematurely
freed. So the test, which was testing that perl didn't crash when
trying to set the length of a freed array, was now trying to set the
size of the array to some large number, and was failing under ASAN.
  • Loading branch information
iabyn committed Nov 16, 2023
1 parent 23ec0ba commit 3d9060f
Showing 1 changed file with 11 additions and 3 deletions.
14 changes: 11 additions & 3 deletions t/op/array.t
Expand Up @@ -498,9 +498,17 @@ sub {
'error when setting alias to -1 elem of empty array';
}->($plink[0], $plink[-2], $plink[-5], $plunk[-1]);

$_ = \$#{[]};
$$_ = \1;
"$$_";
unless (Internals::stack_refcounted() & 1) {
# Skip this test on RC stack builds. The test assumes that the temp
# array has been freed - and so it is just checking that the code
# doesn't crash. But on RC builds the array (correctly) lives on while
# the arylen magic var lives. The assignment ends up using the address
# of \1 as a random number to set the array length to, which can use
# lots of memory!
$_ = \$#{[]};
$$_ = \1;
"$$_";
}
pass "no assertion failure after assigning ref to arylen when ary is gone";


Expand Down

0 comments on commit 3d9060f

Please sign in to comment.