Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

"Not a GLOB reference" 5.10.1 vs. 5.11.3 #10075

Closed
p5pRT opened this issue Jan 12, 2010 · 10 comments
Closed

"Not a GLOB reference" 5.10.1 vs. 5.11.3 #10075

p5pRT opened this issue Jan 12, 2010 · 10 comments

Comments

@p5pRT
Copy link

p5pRT commented Jan 12, 2010

Migrated from rt.perl.org#72038 (status was 'resolved')

Searchable as RT72038$

@p5pRT
Copy link
Author

p5pRT commented Jan 12, 2010

From @kmx

Hi,

I am not sure if this is a bug in perl core or in namespace​::clean, but
what I am sure is that the issue happens on 5.11.3 and does not happen
on 5.10.1 (that is why I have reported it here).

Let us have perl 5.11.3 + namespace​::clean 0.11 and create a module
"XX.pm" like this​:

package XX;
use Socket;
use namespace​::clean;
gethostbyaddr( inet_aton( '127.0.0.1' ), AF_INET );
1;

Then​:

C​:\> perl -e "use XX"
Not a GLOB reference at C​:/perl/site/lib/namespace/clean.pm line 171.
Compilation failed in require at -e line 1.
BEGIN failed--compilation aborted at -e line 1.

It does not happen on perl 5.10.1.

Anyway it is currently a blocker for Catalyst​::Runtime on perl 5.11.3.

The same issue is already reported here (on different platforms)​:
http​://rt.cpan.org/Public/Bug/Display.html?id=53516
http​://www.nntp.perl.org/group/perl.perl5.porters/2009/12/msg154942.html

--
kmx

Perl Info

Flags:
    category=core
    severity=medium

Site configuration information for perl 5.11.3:

Configured by miko at Tue Jan  5 09:08:32 2010.

Summary of my perl5 (revision 5 version 11 subversion 3) configuration:
   
  Platform:
    osname=MSWin32, osvers=4.0, archname=MSWin32-x86-multi-thread
    uname=''
    config_args='undef'
    hint=recommended, useposix=true, d_sigaction=undef
    useithreads=define, usemultiplicity=define
    useperlio=define, d_sfio=undef, uselargefiles=define, usesocks=undef
    use64bitint=undef, use64bitall=undef, uselongdouble=undef
    usemymalloc=n, bincompat5005=undef
  Compiler:
    cc='gcc', ccflags =' -s -O2 -DWIN32 -DHAVE_DES_FCRYPT 
-DPERL_IMPLICIT_CONTEXT -DPERL_IMPLICIT_SYS

-fno-strict-aliasing -mms-bitfields -DPERL_MSVCRT_READFIX',
    optimize='-s -O2',
    cppflags='-DWIN32'
    ccversion='', gccversion='4.4.3', gccosandvers=''
    intsize=4, longsize=4, ptrsize=4, doublesize=8, byteorder=1234
    d_longlong=undef, longlongsize=8, d_longdbl=define, longdblsize=12
    ivtype='long', ivsize=4, nvtype='double', nvsize=8, Off_t='long
long', lseeksize=8
    alignbytes=8, prototype=define
  Linker and Libraries:
    ld='g++', ldflags ='-s -L"c:\perl\lib\CORE" -L"C:\MinGW64\lib"'
    libpth=C:\MinGW64\lib c:\mingw64\i686-w64-mingw32\lib
    libs=-lmoldname -lkernel32 -luser32 -lgdi32 -lwinspool -lcomdlg32
-ladvapi32 -lshell32 -lole32 -loleaut32 -lnetapi32

-luuid -lws2_32 -lmpr -lwinmm -lversion -lodbc32 -lodbccp32 -lcomctl32
    perllibs=-lmoldname -lkernel32 -luser32 -lgdi32 -lwinspool
-lcomdlg32 -ladvapi32 -lshell32 -lole32 -loleaut32

-lnetapi32 -luuid -lws2_32 -lmpr -lwinmm -lversion -lodbc32 -lodbccp32
-lcomctl32
    libc=, so=dll, useshrplib=true, libperl=libperl511.a
    gnulibc_version=''
  Dynamic Linking:
    dlsrc=dl_win32.xs, dlext=dll, d_dlsymun=undef, ccdlflags=' '
    cccdlflags=' ', lddlflags='-mdll -s -L"c:\perl\lib\CORE"
-L"C:\MinGW64\lib"'

Locally applied patches:
    


@INC for perl 5.11.3:
    C:/perl/site/lib
    C:/perl/lib
    .


Environment for perl 5.11.3:
    HOME=c:\home
    LANG (unset)
    LANGUAGE (unset)
    LD_LIBRARY_PATH (unset)
    LOGDIR (unset)
   
PATH=C:\perl\bin;c:\mingw64\bin;C:\WINDOWS\system32;C:\WINDOWS;C:\WINDOWS\System32\Wbem
    PERL_BADLANG (unset)
    SHELL (unset)


@p5pRT
Copy link
Author

p5pRT commented Jan 12, 2010

From p5p@perl.wizbit.be

Citeren kmx <perlbug-followup@​perl.org>​:

I am not sure if this is a bug in perl core or in namespace​::clean, but
what I am sure is that the issue happens on 5.11.3 and does not happen
on 5.10.1 (that is why I have reported it here).

Core only test case​:

#!/usr/bin/perl -l

package XX;

BEGIN { print $]; }

use Symbol qw( qualify_to_ref );

use Socket ("AF_INET");

BEGIN {
  qualify_to_ref("AF_INET", "XX"); # done by namespace​::clean​::imprt
}

BEGIN {
  my $m = ${ "XX​::" }{ AF_INET };
  print qq(\${"XX​::"}{AF_INET} = $m);
  eval {
  local *z = *$m;
  };
  print "ERROR​: $@​" if $@​;
}

my $z = AF_INET;

BEGIN {
  my $m2 = ${ "XX​::" }{ AF_INET };
  print qq(\${"XX​::"}{AF_INET} = $m2);
  eval {
  local *z = *$m2;
  };
  print "ERROR-2​: $@​" if $@​;
}
1;

__END__

Running it with​: and old blead (GitLive-blead-2508-g0d4cbbc) and a
current blead (v5.11.3-86-g73afaec)​:

5.011000
${"XX​::"}{AF_INET} = *XX​::AF_INET
${"XX​::"}{AF_INET} = *XX​::AF_INET


5.011003
${"XX​::"}{AF_INET} = *XX​::AF_INET
${"XX​::"}{AF_INET} = SCALAR(0x89986b0)
ERROR-2​: Not a GLOB reference at XX.pm line 31.

Best regards,

Bram

@p5pRT
Copy link
Author

p5pRT commented Jan 12, 2010

The RT System itself - Status changed from 'new' to 'open'

@p5pRT
Copy link
Author

p5pRT commented Jan 13, 2010

From @rafl

Bisecting says f746176 is the commit
that introduced this bug.

@p5pRT
Copy link
Author

p5pRT commented Jan 13, 2010

From @kmx

Dne út 12.led.2010 14​:08​:31, p5p@​perl.wizbit.be napsal(a)​:
...

Running it with​: and old blead (GitLive-blead-2508-g0d4cbbc) and a
current blead (v5.11.3-86-g73afaec)​:

5.011000
${"XX​::"}{AF_INET} = *XX​::AF_INET
${"XX​::"}{AF_INET} = *XX​::AF_INET

------

5.011003
${"XX​::"}{AF_INET} = *XX​::AF_INET
${"XX​::"}{AF_INET} = SCALAR(0x89986b0)
ERROR-2​: Not a GLOB reference at XX.pm line 31.

Dne út 12.led.2010 18​:28​:06, rafl napsal(a)​:

Bisecting says f746176 is the commit
that introduced this bug.

So is this RT one that "SHOULD BLOCK 5.12"?

--
kmx

@p5pRT
Copy link
Author

p5pRT commented Jan 13, 2010

From zefram@fysh.org

kmx wrote​:

Not a GLOB reference at C​:/perl/site/lib/namespace/clean.pm line 171.

rafl reports, as I suspected, that the core change causing this is
f746176, my patch modifying sub lookups,
which changed the handling of non-globs in the stash. namespace​::clean is
assuming that it'll find a GV in the stash at that point, probably for the
constant sub, and is surprised when it turns out to be in the optimised
RV form. I think ns​:c needs to be changed to handle the non-glob cases.

I can provide a patch for ns​:c. (But I'll feel all dirty working on it.
The way ns​:c operates makes me twitch, and the purpose of the core patch
was specifically to support Lexical​::Var making ns​:c unnecessary.)

-zefram

@p5pRT
Copy link
Author

p5pRT commented Jan 13, 2010

From zefram@fysh.org

Patch for namespace​::clean is attached.

-zefram

@p5pRT
Copy link
Author

p5pRT commented Jan 13, 2010

From zefram@fysh.org

Inline Patch
diff -urN namespace-clean-0.11.orig/MANIFEST namespace-clean-0.11.mod0/MANIFEST
--- namespace-clean-0.11.orig/MANIFEST	2009-03-03 16:38:24.000000000 +0000
+++ namespace-clean-0.11.mod0/MANIFEST	2010-01-13 20:19:20.000000000 +0000
@@ -21,6 +21,7 @@
 t/03-unimport.t
 t/04-except.t
 t/05-explicit-cleanee.t
+t/06-const-sub.t
 t/lib/CleaneeBridge.pm
 t/lib/CleaneeBridgeDirect.pm
 t/lib/CleaneeBridgeExplicit.pm
diff -urN namespace-clean-0.11.orig/lib/namespace/clean.pm namespace-clean-0.11.mod0/lib/namespace/clean.pm
--- namespace-clean-0.11.orig/lib/namespace/clean.pm	2009-03-03 16:30:30.000000000 +0000
+++ namespace-clean-0.11.mod0/lib/namespace/clean.pm	2010-01-13 20:35:28.000000000 +0000
@@ -166,17 +166,27 @@
         next SYMBOL if $store->{exclude}{ $f };
         no strict 'refs';
 
-        # keep original value to restore non-code slots
-        {   no warnings 'uninitialized';    # fix possible unimports
-            local *__tmp = *{ ${ "${cleanee}::" }{ $f } };
-            delete ${ "${cleanee}::" }{ $f };
-        }
+        next SYMBOL unless exists ${ "${cleanee}::" }{ $f };
 
-      SLOT:
-        # restore non-code slots to symbol
-        for my $t (qw( SCALAR ARRAY HASH IO FORMAT )) {
-            next SLOT unless defined *__tmp{ $t };
-            *{ "${cleanee}::$f" } = *__tmp{ $t };
+        if (ref(\${ "${cleanee}::" }{ $f }) eq "GLOB") {
+            # keep original value to restore non-code slots
+            {   no warnings 'uninitialized';    # fix possible unimports
+                local *__tmp = *{ ${ "${cleanee}::" }{ $f } };
+                delete ${ "${cleanee}::" }{ $f };
+            }
+
+          SLOT:
+            # restore non-code slots to symbol
+            for my $t (qw( SCALAR ARRAY HASH IO FORMAT )) {
+                next SLOT unless defined *__tmp{ $t };
+                *{ "${cleanee}::$f" } = *__tmp{ $t };
+            }
+        }
+        else {
+            # A non-glob in the stash is assumed to stand for some kind
+            # of function.  So far they all do, but the core might change
+            # this some day.  Watch perl5-porters.
+            delete ${ "${cleanee}::" }{ $f };
         }
     }
 };
diff -urN namespace-clean-0.11.orig/t/06-const-sub.t namespace-clean-0.11.mod0/t/06-const-sub.t
--- namespace-clean-0.11.orig/t/06-const-sub.t	1970-01-01 01:00:00.000000000 +0100
+++ namespace-clean-0.11.mod0/t/06-const-sub.t	2010-01-13 20:17:57.000000000 +0000
@@ -0,0 +1,11 @@
+#!/usr/bin/env perl
+use warnings;
+use strict;
+
+use Test::More tests => 2;
+
+use constant CONST => 123;
+use namespace::clean;
+my $x = CONST;
+is $x, 123;
+ok eval("!defined(&CONST)");

@p5pRT
Copy link
Author

p5pRT commented Jan 17, 2010

From @rgs

I'm marking this bug as resolved, since it's a matter of adapting
namespace​::clean.

@p5pRT
Copy link
Author

p5pRT commented Jan 17, 2010

@rgs - Status changed from 'open' to 'resolved'

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant