Skip Menu |

This queue is for tickets about the Module-Build CPAN distribution.

Report information
The Basics
Id: 30788
Status: resolved
Priority: 0/
Queue: Module-Build

People
Owner: Nobody in particular
Requestors: andreas.koenig.7os6VVqR [...] franz.ak.mind.de
schwern [...] pobox.com
Cc:
AdminCc:

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



Subject: Version parsing confused by sub version {}
Date: Fri, 16 Nov 2007 12:49:44 -0800
To: List - Module-Build <module-build [...] perl.org>, bug-Module-Build [...] rt.cpan.org
From: Michael G Schwern <schwern [...] pobox.com>
A bug in MakeMaker's parse_version() was found recently. Module::Build has the same bug. https://rt.cpan.org/Ticket/Display.html?id=30747 It's reproducible by getting the version from a module like this: $VERSION = 1.23; sub version { $VERSION } and then this: use version; $VERSION = version->new(2.34); The version() routine pollutes the namespace in which the $VERSION code is evaled. It thinks version->new() is version()->new() calling the polluting version() routine. MakeMaker fixed it by deleting any version() routines from the symbol table before trying to eval the $VERSION code. Here's code to reproduce: $ cat Version_Sub.pm package Version_Sub; $VERSION = 1.23; sub version { $VERSION } 1; $ cat Uses_version.pm package Uses_version.pm; use version; $VERSION = version->new(2.34); 1; $ perl -wle 'use aliased "Module::Build::ModuleInfo"; print ModuleInfo->new_from_file("Version_Sub.pm")->version; print ModuleInfo->new_from_file("Uses_version.pm")->version' 1.23 Can't call method "new" without a package or object reference at (eval 10) line 8, <GEN1> line 3. -- Insulting our readers is part of our business model. http://somethingpositive.net/sp07122005.shtml
CC: List - Module-Build <module-build [...] perl.org>, bug-Module-Build [...] rt.cpan.org
Subject: Re: Version parsing confused by sub version {}
Date: Sat, 17 Nov 2007 10:54:12 +0100
To: Michael G Schwern <schwern [...] pobox.com>
From: andreas.koenig.7os6VVqR [...] franz.ak.mind.de (Andreas J. Koenig)
Show quoted text
>>>>> On Fri, 16 Nov 2007 12:49:44 -0800, Michael G Schwern <schwern@pobox.com> said:
Show quoted text
> A bug in MakeMaker's parse_version() was found recently. Module::Build has > the same bug. > https://rt.cpan.org/Ticket/Display.html?id=30747
Show quoted text
> It's reproducible by getting the version from a module like this:
Show quoted text
> $VERSION = 1.23; sub version { $VERSION }
Show quoted text
> and then this:
Show quoted text
> use version; $VERSION = version->new(2.34);
Show quoted text
> The version() routine pollutes the namespace in which the $VERSION code is > evaled. It thinks version->new() is version()->new() calling the polluting > version() routine. MakeMaker fixed it by deleting any version() routines from > the symbol table before trying to eval the $VERSION code.
A different and slightly less brute fix would probably be to say version::->new() like I do on all package names always everywhere because it's the only safe way to call a method on a package name that has no colons in it. Have you considered this option? -- andreas
Subject: Re: sub version {} pollutes 'eval' package in version parsing
Fixed in svn10264 by incrementing the eval package each time. Yes, we might run out of integers eventually, so delete the eval package afterwards for bonus points.
Subject: Re: [rt.cpan.org #30794] Re: Version parsing confused by sub version {}
Date: Sat, 17 Nov 2007 19:10:07 -0800
To: bug-Module-Build [...] rt.cpan.org
From: Michael G Schwern <schwern [...] pobox.com>
(Andreas J. Koenig) via RT wrote: Show quoted text
> A different and slightly less brute fix would probably be to say > version::->new() like I do on all package names always everywhere > because it's the only safe way to call a method on a package name that > has no colons in it. > > Have you considered this option?
Yes, but the code calling version->new is out of our control. It's in the module who's $VERSION is being parsed. The MakeMaker fix isn't particularly brute force as the context in which $VERSION is eval'd should be clean anyway. -- You know what the chain of command is? It's the chain I go get and beat you with 'til you understand who's in ruttin' command here. -- Jayne Cobb, "Firefly"