This code: sub foo { my $x if @_; return if @_; $x = 17; print $x, "\n"; print sub { $x }->(), "\n"; return; } foo(1); # make $x stale in all perl versions foo; produces errors and wrong output because it stales the $x: 17 Variable "$x" is not available at ./lexical_sub line 11. Use of uninitialized value in print at ./lexical_sub line 11. All perls since 5.10.1 are affected. All Fedoras are affected. Fixed in upstream by commit: commit cae5dbbe30ba4a96ff5e570be0d90779f06fee71 Author: Father Chrysostomos <sprout> Date: Sat Aug 4 14:42:47 2012 -0700 Close over stale vars in active subs
This alone patch applied to 5.16.1 causes failures in t/op/closure.t. This patch pre-requires other patches. And actually lexical subroutines are experimental and upstream has not resolved all problems yet.
I ported five other patches and it still needs other ones. They change internals of cloning contexts and opens series of another mistakes. This bug reports is not resolvable now. It will be fixed in next perl minior version (5.18).