Skip to content

Storable can't locate module because package is in a different file #19259

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

Closed
offsides opened this issue Dec 3, 2021 · 5 comments
Closed

Storable can't locate module because package is in a different file #19259

offsides opened this issue Dec 3, 2021 · 5 comments

Comments

@offsides
Copy link

offsides commented Dec 3, 2021

Module: Storable

Description
Thawing a frozen object containing a Readonly Array or Hash causes perl to crash with the following error:

Can't locate Readonly/Hash.pm in @INC (you may need to install the Readonly::Hash module) (@INC contains: /devel/ftpauto /usr/local/lib64/perl5 /usr/local/share/perl5 /usr/lib64/perl5/vendor_perl /usr/share/perl5/vendor_perl /usr/lib64/perl5 /usr/share/perl5) at /usr/lib64/perl5/vendor_perl/Storable.pm line 464.

(The same error happens except with Readonly/Array.pm and Readonly::Array - it's random which happens because the program in question uses both)

This is because the Readonly::Hash and Readonly::Array packages are located inside Readonly.pm. Note that this did not happen on RHEL 7 using the Perl 5.26 SCL and the exact same code - the only relevant differences are that Readonly is v2.00 on EL7 and 2.05 on EL8.

Steps to Reproduce

perl -e 'use Readonly; use Storable qw(freeze thaw); Readonly my @arr => (1, 2); my %hash = ( scalar => 0, array => \@arr ); my $frozen = freeze \%hash; my %thawed = %{ thaw $frozen };'

Expected behavior
The frozen data structure should be thawed without crashing.

Perl configuration

---
Flags:
    category=core
    severity=low
---
This perlbug was built using Perl 5.26.3 - Thu Jun 17 11:17:47 EDT 2021
It is being executed now by  Perl 5.26.3 - Thu Jun 17 11:18:44 EDT 2021.

Site configuration information for perl 5.26.3:

Configured by Red Hat, Inc. at Thu Jun 17 11:18:44 EDT 2021.

Summary of my perl5 (revision 5 version 26 subversion 3) configuration:
   
  Platform:
    osname=linux
    osvers=4.18.0-193.28.1.el8_2.x86_64
    archname=x86_64-linux-thread-multi
    uname='linux x86-vm-55.build.eng.bos.redhat.com 4.18.0-193.28.1.el8_2.x86_64 #1 smp fri oct 16 13:38:49 edt 2020 x86_64 x86_64 x86_64 gnulinux '
    config_args='-des -Doptimize=none -Dccflags=-O2 -g -pipe -Wall -Werror=format-security -Wp,-D_FORTIFY_SOURCE=2 -Wp,-D_GLIBCXX_ASSERTIONS -fexceptions -fstack-protector-strong -grecord-gcc-switches -specs=/usr/lib/rpm/redhat/redhat-hardened-cc1 -specs=/usr/lib/rpm/redhat/redhat-annobin-cc1 -m64 -mtune=generic -fasynchronous-unwind-tables -fstack-clash-protection -fcf-protection -Dldflags=-Wl,-z,relro  -Wl,-z,now -specs=/usr/lib/rpm/redhat/redhat-hardened-ld -Dccdlflags=-Wl,--enable-new-dtags -Wl,-z,relro  -Wl,-z,now -specs=/usr/lib/rpm/redhat/redhat-hardened-ld -Dlddlflags=-shared -Wl,-z,relro  -Wl,-z,now -specs=/usr/lib/rpm/redhat/redhat-hardened-ld -Dshrpdir=/usr/lib64 -DDEBUGGING=-g -Dversion=5.26.3 -Dmyhostname=localhost -Dperladmin=root@localhost -Dcc=gcc -Dcf_by=Red Hat, Inc. -Dprefix=/usr -Dvendorprefix=/usr -Dsiteprefix=/usr/local -Dsitelib=/usr/local/share/perl5 -Dsitearch=/usr/local/lib64/perl5 -Dprivlib=/usr/share/perl5 -Dvendorlib=/usr/share/perl5/vendor_perl -Darchlib=/usr/lib64/perl5 -Dvendorarch=/usr/lib64/perl5/vendor_perl -Darchname=x86_64-linux-thread-multi -Dlibpth=/usr/local/lib64 /lib64 /usr/lib64 -Duseshrplib -Dusethreads -Duseithreads -Dusedtrace=/usr/bin/dtrace -Duselargefiles -Dd_semctl_semun -Di_db -Ui_ndbm -Di_gdbm -Di_shadow -Di_syslog -Dman3ext=3pm -Duseperlio -Dinstallusrbinperl=n -Ubincompat5005 -Uversiononly -Dpager=/usr/bin/less -isr -Dd_gethostent_r_proto -Ud_endhostent_r_proto -Ud_sethostent_r_proto -Ud_endprotoent_r_proto -Ud_setprotoent_r_proto -Ud_endservent_r_proto -Ud_setservent_r_proto -Dscriptdir=/usr/bin -Dusesitecustomize -Duse64bitint'
    hint=recommended
    useposix=true
    d_sigaction=define
    useithreads=define
    usemultiplicity=define
    use64bitint=define
    use64bitall=define
    uselongdouble=undef
    usemymalloc=n
    default_inc_excludes_dot=define
    bincompat5005=undef
  Compiler:
    cc='gcc'
    ccflags ='-D_REENTRANT -D_GNU_SOURCE -O2 -g -pipe -Wall -Werror=format-security -Wp,-D_FORTIFY_SOURCE=2 -Wp,-D_GLIBCXX_ASSERTIONS -fexceptions -fstack-protector-strong -grecord-gcc-switches -specs=/usr/lib/rpm/redhat/redhat-hardened-cc1 -specs=/usr/lib/rpm/redhat/redhat-annobin-cc1 -m64 -mtune=generic -fasynchronous-unwind-tables -fstack-clash-protection -fcf-protection -fwrapv -fno-strict-aliasing -I/usr/local/include -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64'
    optimize='  -g'
    cppflags='-D_REENTRANT -D_GNU_SOURCE -O2 -g -pipe -Wall -Werror=format-security -Wp,-D_FORTIFY_SOURCE=2 -Wp,-D_GLIBCXX_ASSERTIONS -fexceptions -fstack-protector-strong -grecord-gcc-switches -specs=/usr/lib/rpm/redhat/redhat-hardened-cc1 -specs=/usr/lib/rpm/redhat/redhat-annobin-cc1 -m64 -mtune=generic -fasynchronous-unwind-tables -fstack-clash-protection -fcf-protection -fwrapv -fno-strict-aliasing -I/usr/local/include'
    ccversion=''
    gccversion='8.5.0 20210514 (Red Hat 8.5.0-2)'
    gccosandvers=''
    intsize=4
    longsize=8
    ptrsize=8
    doublesize=8
    byteorder=12345678
    doublekind=3
    d_longlong=define
    longlongsize=8
    d_longdbl=define
    longdblsize=16
    longdblkind=3
    ivtype='long'
    ivsize=8
    nvtype='double'
    nvsize=8
    Off_t='off_t'
    lseeksize=8
    alignbytes=8
    prototype=define
  Linker and Libraries:
    ld='gcc'
    ldflags ='-Wl,-z,relro -Wl,-z,now -specs=/usr/lib/rpm/redhat/redhat-hardened-ld -fstack-protector-strong -L/usr/local/lib'
    libpth=/usr/local/lib64 /lib64 /usr/lib64 /usr/local/lib /usr/lib /lib/../lib64 /usr/lib/../lib64 /lib
    libs=-lpthread -lresolv -lgdbm -ldb -ldl -lm -lcrypt -lutil -lc -lgdbm_compat
    perllibs=-lpthread -lresolv -ldl -lm -lcrypt -lutil -lc
    libc=libc-2.28.so
    so=so
    useshrplib=true
    libperl=libperl.so
    gnulibc_version='2.28'
  Dynamic Linking:
    dlsrc=dl_dlopen.xs
    dlext=so
    d_dlsymun=undef
    ccdlflags='-Wl,--enable-new-dtags -Wl,-z,relro -Wl,-z,now -specs=/usr/lib/rpm/redhat/redhat-hardened-ld'
    cccdlflags='-fPIC'
    lddlflags='-lpthread -shared -Wl,-z,relro -Wl,-z,now -specs=/usr/lib/rpm/redhat/redhat-hardened-ld -L/usr/local/lib -fstack-protector-strong'

Locally applied patches:
    Fedora Patch1: Removes date check, Fedora/RHEL specific
    Fedora Patch3: support for libdir64
    Fedora Patch4: use libresolv instead of libbind
    Fedora Patch5: USE_MM_LD_RUN_PATH
    Fedora Patch6: Provide MM::maybe_command independently (bug #1129443)
    Fedora Patch7: Dont run one io test due to random builder failures
    Fedora Patch15: Define SONAME for libperl.so
    Fedora Patch16: Install libperl.so to -Dshrpdir value
    Fedora Patch22: Document Math::BigInt::CalcEmu requires Math::BigInt (CPAN RT#85015)
    Fedora Patch26: Make *DBM_File desctructors thread-safe (RT#61912)
    Fedora Patch27: Make PadlistNAMES() lvalue again (CPAN RT#101063)
    Fedora Patch30: Replace EU::MakeMaker dependency with EU::MM::Utils in IPC::Cmd (bug #1129443)
    Fedora Patch31: Make File::Glob more resistant against degenerative matching (RT#131211)
    Fedora Patch36: Fix glob UTF-8 flag on a glob reassignment (RT#131263)
    Fedora Patch38: Fix handling backslashes in PATH environment variable when executing "perl -S" (RT#129183)
    Fedora Patch45: Fix File::Glob rt131211.t test random failures
    Fedora Patch46: Fix t/op/hash.t test random failures
    Fedora Patch47: Parse caret variables with subscripts as normal variables inside ${...} escaping (RT#131664)
    Fedora Patch49: Do not display too many bytes when reporting malformed UTF-8 character
    Fedora Patch51: Fix error message for "our sub foo::bar" (RT#131679)
    Fedora Patch52: Fix executing arybase::_tie_it() in Safe compartement (RT#131588)
    Fedora Patch54: Fix splitting non-ASCII strings if unicode_strings feature is enabled (RT#130907)
    Fedora Patch55: Fix compiler warnings in code generated by ExtUtils::Constant (CPAN RT#63832)
    Fedora Patch56: Fix compiler warnings in code generated by ExtUtils::Constant (CPAN RT#101487)
    Fedora Patch58: Fix unreliable Time-HiRes tests (CPAN RT#122819)
    Fedora Patch61: Fix Term::ReadLine not to create spurious &STDERR files (RT#132008)
    Fedora Patch64: Fix an overflow when parsing a character range with no preceding character (RT#132245)
    Fedora Patch65: Fix walking symbol table for ISA in Carp
    Fedora Patch66: Fix handling file names with null bytes in stat and lstat functions (RT#131895)
    Fedora Patch67: Fix a crash when untying an object witout a stash
    Fedora Patch68: Fix deparsing of transliterations with unprintable characters (RT#132405)
    Fedora Patch69: Fix error reporting on do() on a directory (RT#125774)
    Fedora Patch70: Fix stack manipulation when a lexical subroutine is defined in a do block in a member of an iteration list (RT#132442)
    Fedora Patch71: Fix setting $! when statting a closed filehandle (RT#108288)
    Fedora Patch72: Fix tainting of s/// with overloaded replacement (RT#115266)
    Fedora Patch73: Expand system() arguments before a fork (RT#121105)
    Fedora Patch76: Avoid undefined behavior when copying memory in Glob and pp_caller (RT#131746)
    Fedora Patch78: Fix compatibility with libxcrypt (RT#133184)
    Fedora Patch79: Link XS modules to pthread library to fix linking with -z defs
    Fedora Patch80: Fix parsing braced subscript after parentheses (RT#8045)
    Fedora Patch81: Do not clobber file bytes in :encoding layer (RT#132833)
    Fedora Patch82: Fix line numbers in multi-line s/// (RT#131930)
    Fedora Patch83: Fix parsing extended bracketed character classes (RT#132167)
    Fedora Patch84: Fix a possibly unitialized memory read in the Perl parser (RT#133074)
    Fedora Patch85: Fix an infinite loop in the regular expression compiler (RT#133185)
    Fedora Patch86: Adjust tests to gdbm-1.15 (RT#133295)
    Fedora Patch88: Fix printing a warning about a wide character when matching a regular expression while ISO-8859-1 locale is in effect
    Fedora Patch89: Fix invoking a check for wide characters while ISO-8859-1 locale is in effect
    Fedora Patch90: Pass the correct CFLAGS to dtrace
    RHEL Patch91: Fix Time-Local tests to pass after year 2019 (bug #1807120)
    RHEL Patch92: Fix CVE-2020-12723 (GH#16947)
    RHEL Patch93: Fix CVE-2020-10543
    RHEL Patch94: Fix CVE-2020-10878
    RHEL Patch95: Fix Net-Ping _resolv return value on failing DNS name lookup (bug #1973030)
    Fedora Patch200: Link XS modules to libperl.so with EU::CBuilder on Linux
    Fedora Patch201: Link XS modules to libperl.so with EU::MM on Linux

---
@INC for perl 5.26.3:
    /usr/local/lib64/perl5
    /usr/local/share/perl5
    /usr/lib64/perl5/vendor_perl
    /usr/share/perl5/vendor_perl
    /usr/lib64/perl5
    /usr/share/perl5

---
Environment for perl 5.26.3:
    HOME=/home/ftpauto
    LANG=en_US.UTF-8
    LANGUAGE (unset)
    LD_LIBRARY_PATH (unset)
    LOGDIR (unset)
    PATH=/home/ftpauto/.local/bin:/home/ftpauto/bin:/usr/local/bin:/usr/bin:/usr/local/sbin:/usr/sbin
    PERL_BADLANG (unset)
    SHELL=/bin/bash
@jkeenan
Copy link
Contributor

jkeenan commented Dec 3, 2021

Module: Storable

Description Thawing a frozen object containing a Readonly Array or Hash causes perl to crash with the following error:

Can't locate Readonly/Hash.pm in @INC (you may need to install the Readonly::Hash module) (@INC contains: /devel/ftpauto /usr/local/lib64/perl5 /usr/local/share/perl5 /usr/lib64/perl5/vendor_perl /usr/share/perl5/vendor_perl /usr/lib64/perl5 /usr/share/perl5) at /usr/lib64/perl5/vendor_perl/Storable.pm line 464.

(The same error happens except with Readonly/Array.pm and Readonly::Array - it's random which happens because the program in question uses both)

Can you explain why you believe this should be classified as a bug in Storable (which is maintained here in core) rather than a bug in Readonly (which is maintained upstream on CPAN)?

@offsides
Copy link
Author

offsides commented Dec 3, 2021

I would have thought that since the Readonly.pm file contains the (e.g.) Readonly::Hash package, that it would already be in the namespace and thus thawing an object containing a Readonly hash would not cause an error. That said, it appears that perhaps that's not the case. Also, as I dug deeper, it appears that Readonly 2.02 added a STORABLE_freeze function to Readonly::Scalar, Readonly::Array and Readonly::Hash, and that those functions are what's causing this issue. Here's the Array function, but they're essentially the same just for different data types:

sub STORABLE_freeze {
    my ($self, $cloning) = @_;
    Readonly::_ARRAY(@$self) if $cloning;
}

Commenting those functions out of the Readonly module resolves the issue, so it may well be that it really is a Readonly problem. That said, it was reported to the maintainer 5 years ago and his response was that the reporter could fork, fix and submit a PR, but that's all they were doing. So if you have any suggestions on how to fix Readonly instead, I'll be happy to try to work with them and go that route.

@jkeenan
Copy link
Contributor

jkeenan commented Dec 3, 2021

Commenting those functions out of the Readonly module resolves the issue, so it may well be that it really is a Readonly problem. That said, it was reported to the maintainer 5 years ago and his response was that the reporter could fork, fix and submit a PR, but that's all they were doing.

I agree that this module's bug queue is getting long. Can you identify the specific bug ticket you're mentioning?

@offsides
Copy link
Author

offsides commented Dec 3, 2021

Readonly Issue #27. That said, I found a reference to ReadonlyX which appears to be the same author rewriting Readonly as a near drop-in replacement without the legacy issues, and it works with Storable. So I'm inclined to just switch to using that and see if it has problems, and if not I'll call it a day. In any event, I now agree that this is most likely not a Storable issue, but a Readonly issue, so I'm fine if you want to close this issue out.

@jkeenan
Copy link
Contributor

jkeenan commented Dec 3, 2021

Thank you for taking the time to dig deeper into this. Closing ticket per your recommendation.

@jkeenan jkeenan closed this as completed Dec 3, 2021
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