Skip Menu |

This queue is for tickets about the indirect CPAN distribution.

Report information
The Basics
Id: 64521
Status: stalled
Priority: 0/
Queue: indirect

People
Owner: Nobody in particular
Requestors: mschwern [...] cpan.org
Cc:
AdminCc:

Bug Information
Severity: Important
Broken in: 0.23
Fixed in: (no value)



Subject: "no indirect" leaking into eval
I found a case where "no indirect" is leaking out of it's lexical scope and into evals. If you load the attached module in the presence of "no indirect" it will fail with: Indirect call of method "import" on object "Test::Warn" at (eval 31) line 1. Indirect call of method "import" on object "Test::Exception" at (eval 32) line 1. Indirect call of method "import" on object "Test::Differences" at (eval 33) line 1. Indirect call of method "import" on object "Test::Deep" at (eval 34) line 1. These appear to stem from this line in Test::Most: eval "require $module; import $module $exclude_symbols;"; which is using an indirect method call, but is not in indirect's scope. What's interesting is this is not a problem with loading Test::Most directly. It only happens when Test::Most->import is called and then called again inside an import at BEGIN time. Removing either the BEGIN block or the call to import from test.plx makes the problem go away. Hope that's enough info. perl -V attached.
Subject: TestMost.pm
package TestMost; # Import Test::Most's symbols and re-export them require Test::Most; Test::Most->import; Test::Most->import; sub import { Test::Most->import; } 1;
Subject: perlV.out
Download perlV.out
application/octet-stream 2.8k

Message body not shown because it is not plain text.

Subject: test.plx
Download test.plx
application/octet-stream 114b

Message body not shown because it is not plain text.

This is not an indirect bug and is a side effect of how the lexical hints hash work. The test case can be reduced to # ------------------------------------------------------------- #!perl package X; # plays the role of Test::Most sub import { my $module = 'Carp'; if ($module->isa('Exporter')) { print "require $module\n"; eval "require $module; print qq[wut\\n] if \$^H{wut}" } else { print "use $module\n"; eval "use $module;" } } package Y; # plays the role of TestMost sub import { shift; X->import for 1 .. $_[0]; } package main; BEGIN { $^H |= 0x20000; $^H{wut} = 1; } BEGIN { Y->import($ARGV[0]); } # ------------------------------------------------------------- (see the y.t file attached) $ perl y.t 1 use Carp $ perl y.t 2 use Carp require Carp wut $^H{wut} (playing the role of indirect) is set in the BEGIN block in which Y->import is called, thus it is also set in all Y->import's callees (see perldoc perlvar, %^H). The first time X->import is called, Carp isn't loaded yet so Carp->isa('Exporter') is false. The second branch is then executed, which only does an eval "use $module", without any indirect construct. The second time, Carp is loaded so the first branch is executed, and the indirect construct is reported (here, "wut" is printed). If anything, one may say that there is a bug in indirect with perl version 5.10.0 and earlier, for which your test case does not produce any indirect violations. This is because the workaround used in indirect to fix some other leaking bugs of %^H is actually stricter than the expected "correct" behaviour of %^H. The behaviour of indirect with perl version 5.10.1 and greater is in line with how %^H works. Vincent.
Subject: y.t
#!perl package X; sub import { my $module = 'Carp'; if ($module->isa('Exporter')) { print "require $module\n"; eval "require $module; print qq[wut\\n] if \$^H{wut}" } else { print "use $module\n"; eval "use $module;" } } package Y; sub import { shift; X->import for 1 .. $_[0]; } package main; BEGIN { $^H |= 0x20000; $^H{wut} = 1; } BEGIN { Y->import($ARGV[0]); }
Apologies, I was being an idiot. This is a legitimate bug and I'll fix it as soon as possible. Thanks for the report. Vincent.
Subject: Re: [rt.cpan.org #64521] "no indirect" leaking into eval
Date: Sat, 08 Jan 2011 17:59:07 +1100
To: bug-indirect [...] rt.cpan.org
From: Michael G Schwern <schwern [...] pobox.com>
On 2011.1.7 11:56 PM, Vincent Pit via RT wrote: Show quoted text
> Apologies, I was being an idiot. This is a legitimate bug and I'll fix > it as soon as possible. Thanks for the report.
What did it turn out to be? -- Being faith-based doesn't trump reality. -- Bruce Sterling
Ping?
Show quoted text
> Ping?
I know how to fix it for 5.10, but it will be harder to get it right for 5.8.
Subject: Re: [rt.cpan.org #64521] "no indirect" leaking into eval
Date: Sat, 19 Feb 2011 15:12:41 +1100
To: bug-indirect [...] rt.cpan.org
From: Michael G Schwern <schwern [...] pobox.com>
On 2011.2.18 9:42 PM, Vincent Pit via RT wrote: Show quoted text
> I know how to fix it for 5.10, but it will be harder to get it right for > 5.8.
I'd be happy with 5.10 working. -- 24. Must not tell any officer that I am smarter than they are, especially if it's true. -- The 213 Things Skippy Is No Longer Allowed To Do In The U.S. Army http://skippyslist.com/list/
Show quoted text
> I'd be happy with 5.10 working. > >
That module supports 5.8 so I don't know when you'll be happy.
Subject: Re: [rt.cpan.org #64521] "no indirect" leaking into eval
Date: Sun, 20 Feb 2011 18:20:07 +1100
To: bug-indirect [...] rt.cpan.org
From: Michael G Schwern <schwern [...] pobox.com>
On 2011.2.19 9:36 PM, Vincent Pit via RT wrote: Show quoted text
> <URL: https://rt.cpan.org/Ticket/Display.html?id=64521 >
>> I'd be happy with 5.10 working.
> > That module supports 5.8 so I don't know when you'll be happy.
Can this bug be fixed in 5.10 without breaking 5.8 further? -- The interface should be as clean as newly fallen snow and its behavior as explicit as Japanese eel porn.
RT-Send-CC: schwern [...] pobox.com
This bug has been fixed for perl 5.10 in version 0.24. I'm marking it at stalled while I design the proper fix for perl 5.8. Thanks again for reporting the issue. Vincent.