develooper Front page | perl.perl5.porters | Postings from January 2005

Re: [perl #33927] [BUG] Coredump in 5.9.2 when evalling a certainstring while in a coderf in @INC

Thread Previous | Thread Next
John Peacock
January 25, 2005 10:54
Re: [perl #33927] [BUG] Coredump in 5.9.2 when evalling a certainstring while in a coderf in @INC
Message ID: (via RT) wrote:
>     package core;
>     use strict;
>     sub import {
>         require lib;
>         lib->import( sub { eval q[*UNIVERSAL::VERSION = $old_version] })
>     }    
>     1;

Examining the code in Module::Build::Base, I can see why this would coredump, 
since you stripped out all of the important bits.  Effectively you are nuking 
the &UNIVERSAL::VERSION subroutine.  To quote the original code:

   # will change the ->VERSION method, so we mitigate the
   # potential effects here.  Unfortunately local(*UNIVERSAL::VERSION)
   # will crash perl < 5.8.1.

   my $old_version = \&UNIVERSAL::VERSION;
   eval {require version};
   my $result = eval $eval;
   *UNIVERSAL::VERSION = $old_version;

Here, $old_version is a reference to the original &UNIVERSAL::VERSION sub and it 
is being captured before attempting to load the compatibility module, 
then restored afterwords.

However, in your code, you are assigning a null scalar to the glob, thuse wiping 
out the &UNIVERSAL::VERSION sub.  The next module to be use'd will henceforth 
call an null sub and blow bits all over the place.

If you tell me what you are actually attempting to do, I might be able to 
suggest something different.  I disagreed with the way that M::B was changed as 
described in the comment above, so it may be that this issue will have to be 
reopened with the M::B folks.  If this is related to the laudable attempt to 
move M::B into the core, the above code will have no effect whatsoever, since 
the module is a stub in 5.9+; all of the UNIVERSAL::VERSION changes 
are in the core already.


John Peacock
Director of Information Research and Technology
Rowman & Littlefield Publishing Group
4720 Boston Way
Lanham, MD 20706
301-459-3366 x.5010
fax 301-429-5747

Thread Previous | Thread Next Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at | Group listing | About