develooper Front page | perl.perl5.porters | Postings from October 2003

Caching requires (was Re: 5.8.2 perldelta)

From:
Rick Delaney
Date:
October 30, 2003 21:11
Subject:
Caching requires (was Re: 5.8.2 perldelta)
Message ID:
20031031001011.B4927@biff.bort.ca
On Fri, Oct 31, 2003 at 01:24:53AM +0000, hv@crypt.org wrote:
> Stas Bekman <stas@stason.org> wrote:
> :Nicholas Clark wrote:
> :
> :>>Dave, please see my followup to p5p. The patch 21496 is the one that broke 
> :>>mp1 test suite.
> :> 
> :> 
> :> I have reverted this change. I'll reconsider an improved version
> :> for 5.8.3.
> :
> :Thanks Nick.
> :
> :> Both remain in blead. (until/unless Hugo says otherwise)
> :
> :For the blead case, does the test that I've posted seem to be a valid one that 
> :shows that this patch breaks things?
> :http://www.xray.mpe.mpg.de/mailing-lists/perl5-porters/2003-10/msg01457.html
> :Hugo?
> 
> I think it is valid, but not sufficient.

I'm not sure it's even valid.  This line:

    chdir $expected_failure ? $not_cwd : $cwd;

doesn't do what you think it does.  Try 

    chdir($expected_failure ? $not_cwd : $cwd) or die;

instead.  Test results become identical pre- and post-patch with this
fix.

As to the original problem:

    Imagine a real world situation: program A tries to load module Foo, but
    fails for some reason. Now program B tries to load module Foo and it 
    succeeds (e.g.  this time loaded from the proper directory, or some other 
    condition became true). Now run both program from a persistent enviroment 
    like mod_perl.  Program A prevents from program B to load module Foo. The 
    only way to fix that problem is to delete $INC{"Foo.pm"} in program B.

This is not the only way.  Since module Foo is relying on dynamic
loading conditions it has the option of returning 0 instead of croaking
when conditions aren't right but may become right later.  This will
defeat the caching mechanism.

In any case, the above problem exists in older perls too since failures
were always cached; they were just cached as successes before.  My
apologies if I'm missing the point somewhere.  I haven't been following
this thread with the scintillating subject of "5.8.2 perldelta".

> That makes 7 tests, all of which I think perl should pass.

Assuming that the test wasn't buggy, I'm not convinced that the 

    exists $INC{$file}

tests should necessarily pass.  We could just as easily cache failures
in a separate internal hash.  I like Nick's suggestion of
PL_sv_placeholder.  That also wouldn't show up under exists, right?
But to test for this in pp_require, do we have an hv_fetch equivalent 
that will return PL_sv_placeholder or should we just add a flag?  I'll
look at changing this in blead if no one objects.

-- 
Rick Delaney
rick@bort.ca



nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About