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

use Module; fails silently with wrong cased module name on Windows #14926

Open
p5pRT opened this issue Sep 24, 2015 · 4 comments
Open

use Module; fails silently with wrong cased module name on Windows #14926

p5pRT opened this issue Sep 24, 2015 · 4 comments

Comments

@p5pRT
Copy link

p5pRT commented Sep 24, 2015

Migrated from rt.perl.org#126167 (status was 'open')

Searchable as RT126167$

@p5pRT
Copy link
Author

p5pRT commented Sep 24, 2015

From beasley@web.de

Created by beasley@web.de

Some code to illustrate the Problem​:

C​:\data\bla>echo package Module; sub import { print "Import called.\n"; }; 1;

Module.pm

C​:\data\bla>perl -E "use Module; print 'Called.';"
Import called.
Called.

C​:\data\bla>perl -E "use MODULE; print 'Called.';"
Called.

C​:\data\bla>perl -E "use MOE; print 'Called.';"
Can't locate MOE.pm in @​INC (you may need to install the MOE module) (@​INC
contains​: C​:/berrybrew/5.22.0_64/perl/site/lib/MSWin32-x64-multi-thread
C​:/berrybrew/5.22.0_64/perl/site/lib C​:/berrybrew/5.22.0_64/perl/vendor/lib
C​:/berrybrew/5.22.0_64/perl/lib .) at -e line 1.
BEGIN failed--compilation aborted at -e line 1.

C​:\data\bla>perl -v
This is perl 5, version 22, subversion 0 (v5.22.0) built for MSWin32-x64-multi-
thread

(Strawberry Perl installed by berrybrew)

Perl Info

Flags:
    category=core
    severity=medium

Site configuration information for perl 5.22.0:

Configured by strawberry-perl at Tue Jun  2 00:01:02 2015.

Summary of my perl5 (revision 5 version 22 subversion 0) configuration:
   
  Platform:
    osname=MSWin32, osvers=6.3, archname=MSWin32-x64-multi-thread
    uname='Win32 strawberry-perl 5.22.0.1 #1 Mon Jun  1 23:58:39 2015 x64'
    config_args='undef'
    hint=recommended, useposix=true, d_sigaction=undef
    useithreads=define, usemultiplicity=define
    use64bitint=define, use64bitall=undef, uselongdouble=undef
    usemymalloc=n, bincompat5005=undef
  Compiler:
    cc='gcc', ccflags =' -s -O2 -DWIN32 -DWIN64 -DCONSERVATIVE  -
DPERL_TEXTMODE_SCRIPTS -DPERL_IMPLICIT_CONTEXT -DPERL_IMPLICIT_SYS -fwrapv -
fno-strict-aliasing -mms-bitfields',
    optimize='-s -O2',
    cppflags='-DWIN32'
    ccversion='', gccversion='4.9.2', gccosandvers=''
    intsize=4, longsize=4, ptrsize=8, doublesize=8, byteorder=12345678, 
doublekind=3
    d_longlong=define, longlongsize=8, d_longdbl=define, longdblsize=8, 
longdblkind=3
    ivtype='long long', ivsize=8, nvtype='double', nvsize=8, Off_t='long long', 
lseeksize=8
    alignbytes=8, prototype=define
  Linker and Libraries:
    ld='g++.exe', ldflags ='-s -L"C:\berrybrew\5.22.0_64\perl\lib\CORE" -L"C:
\berrybrew\5.22.0_64\c\lib"'
    libpth=C:\berrybrew\5.22.0_64\c\lib C:\berrybrew\5.22.0_64\c\x86_64-w64-
mingw32\lib C:\berrybrew\5.22.0_64\c\lib\gcc\x86_64-w64-mingw32\4.9.2
    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=libperl522.a
    gnulibc_version=''
  Dynamic Linking:
    dlsrc=dl_win32.xs, dlext=xs.dll, d_dlsymun=undef, ccdlflags=' '
    cccdlflags=' ', lddlflags='-mdll -s -L"C:\berrybrew\5.22.0_64\perl\lib\CORE" 
-L"C:\berrybrew\5.22.0_64\c\lib"'



@INC for perl 5.22.0:
    C:/berrybrew/5.22.0_64/perl/site/lib/MSWin32-x64-multi-thread
    C:/berrybrew/5.22.0_64/perl/site/lib
    C:/berrybrew/5.22.0_64/perl/vendor/lib
    C:/berrybrew/5.22.0_64/perl/lib
    .


Environment for perl 5.22.0:
    HOME=H:\home
    LANG=DE
    LANGUAGE (unset)
    LD_LIBRARY_PATH (unset)
    LOGDIR (unset)
    PATH=C:\ProgramData\Oracle\Java\javapath;C:\Windows\system32;C:\Windows;C:
\Windows\System32\Wbem;C:\Windows\System32\WindowsPowerShell\v1.0\;C:\Program 
Files (x86)\MySQL\MySQL Utilities 1.3.4\;C:\Program Files (x86)\Git\cmd;C:
\Program Files (x86)\sbt\bin;C:\Program Files (x86)\scala\bin;C:\Program 
Files\Microsoft\Web Platform Installer\;C:\Program Files (x86)\Microsoft 
ASP.NET\ASP.NET Web Pages\v1.0\;C:\Program Files (x86)\Windows 
Kits\8.0\Windows Performance Toolkit\;C:\Program Files\Microsoft SQL 
Server\110\Tools\Binn\;C:\Program Files\TortoiseSVN\bin;C:
\ProgramData\Oracle\Java\javapath;C:\Windows\system32;C:\Windows;C:
\Windows\System32\Wbem;C:\Windows\System32\WindowsPowerShell\v1.0\;C:\Program 
Files (x86)\MySQL\MySQL Utilities 1.3.4\;C:\Program Files (x86)\Git\cmd;C:
\Program Files (x86)\sbt\bin;C:\Program Files (x86)\scala\bin;C:\Program 
Files\Microsoft\Web Platform Installer\;C:\Program Files (x86)\Microsoft 
ASP.NET\ASP.NET Web Pages\v1.0\;C:\Program Files (x86)\Windows 
Kits\8.0\Windows Performance Toolkit\;C;C:\data\berrybrew\bin;C:
\berrybrew\5.22.0_64\c\bin;C:\berrybrew\5.22.0_64\perl\bin;C:
\berrybrew\5.22.0_64\perl\site\bin
    PERL_BADLANG (unset)
    SHELL (unset)

@p5pRT
Copy link
Author

p5pRT commented Sep 24, 2015

From @karenetheridge

On Thu Sep 24 10​:35​:32 2015, beasley@​web.de wrote​:

C​:\data\bla>echo package Module; sub import { print "Import
called.\n"; }; 1;

Module.pm

C​:\data\bla>perl -E "use Module; print 'Called.';"
Import called.
Called.

C​:\data\bla>perl -E "use MODULE; print 'Called.';"
Called.

Isn't this expected behaviour for case-insensitive filesystems?

@p5pRT
Copy link
Author

p5pRT commented Sep 24, 2015

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

@p5pRT
Copy link
Author

p5pRT commented Sep 24, 2015

From zefram@fysh.org

Patrick Zimmermann wrote​:

C​:\data\bla>perl -E "use MODULE; print 'Called.';"
Called.

This is a known problem, and the natural result of the combination of
some intentional features. The module file is found, because of the
filesystem's aliasing. Reading the file, Perl cannot tell that it is
intended to be a differently-named module, because a module file is
nothing more than a file of Perl code to be executed when the module is
called for. The module thus loads pretty much as intended, and (per
convention) establishes named items in the package corresponding to
the name that the module thinks it has, which is contained in the file,
not the name under which it is being loaded.

Finally, the ->import method is called on the package corresponding to
the name under which the module was loaded. There is no such method
installed, because of the name mismatch, so one might expect an error
here. But for historical reasons in the module API, the existence of
an ->import method is optional​: in its absence, calling it silently
does nothing. Hence the result that you see.

The result is less than awesome. But no part of the structure that
leads to it is an outright bug. Getting a better result would require an
incompatible change to a working feature. Previous discussion has not
yielded any consensus on which part should change, or even on whether
it's worth making such a change to avoid this problem.

Incidentally, I've seen the same result from a module file that misspelled
its own name in its internal package declaration. This similarly led
to the module loading happily but the ->import call finding nothing.
It was not fun to figure that one out. Removing the special case for a
missing ->import would have the attraction of addressing this class of
problem as well. (In the absence of that sort of fix, I ensured that it
couldn't happen again in that codebase by adding a .t that just checks
that every module starts with a package declaration with the right name.)

My main opinion on this is that the filesystem lookup method should
change. The arrangement of using a case-insensitive filesystem's name
handling directly is deficient, because, in addition to this unwanted
aliasing, it makes it impossible to have two modules installed under the
same @​INC prefix whose names differ only in case. Perl's module/package
naming does support such distinctions, and on most targets we get it,
so deficient filesystems need to be worked around in order to get a
fully working Perl system on those platforms. I.e., we need a layer of
name mangling.

-zefram

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

No branches or pull requests

2 participants