Bug 846330 - Lexical subroutines make some variables unavailable
Lexical subroutines make some variables unavailable
Product: Fedora
Classification: Fedora
Component: perl (Show other bugs)
Unspecified Unspecified
unspecified Severity unspecified
: ---
: ---
Assigned To: Marcela Mašláňová
Fedora Extras Quality Assurance
Depends On:
  Show dependency treegraph
Reported: 2012-08-07 09:25 EDT by Petr Pisar
Modified: 2012-09-11 08:01 EDT (History)
11 users (show)

See Also:
Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of:
Last Closed: 2012-09-11 08:01:25 EDT
Type: Bug
Regression: ---
Mount Type: ---
Documentation: ---
Verified Versions:
Category: ---
oVirt Team: ---
RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: ---

Attachments (Terms of Use)

  None (edit)
Description Petr Pisar 2012-08-07 09:25:34 EDT
This code:

sub foo {
    my $x if @_;
    return if @_;

    $x = 17;
    print $x, "\n";
    print sub { $x }->(), "\n";

foo(1); # make $x stale in all perl versions

produces errors and wrong output because it stales the $x:

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@cpan.org>
Date:   Sat Aug 4 14:42:47 2012 -0700

    Close over stale vars in active subs
Comment 1 Petr Pisar 2012-09-11 07:06:44 EDT
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.
Comment 2 Petr Pisar 2012-09-11 08:01:25 EDT
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).

Note You need to log in before you can comment on or make changes to this bug.