Module: core feature 'class'
Description
Referencing a required :param
class member in DESTROY, which had not been correctly initialised during instantiation, triggered a Segmentation fault.
FAO @leonerd, @ilmari - following up on IRC conversation. Many thanks!
Steps to Reproduce
This script is the most whittled-down example I could produce which exhibits the behaviour:
#!/usr/bin/env perl use v5.40; use experimental qw/ class /; class Foo { field $dependency :param :reader; DESTROY { shift->dependency->cleanup; } } # Ooops, forgot to supply the dependency Foo->new;
Expected behavior
Additional error:
Can't call method "cleanup" on an undefined value
Perl configuration
$ perl -V
Summary of my perl5 (revision 5 version 40 subversion 0) configuration:
Platform:
osname=linux
osvers=6.6.23
archname=x86_64-linux
uname='linux hollister.home.fuzzix.org 6.6.23 #1 smp preempt_dynamic wed mar 27 13:34:48 cdt 2024 x86_64 intel(r) core(tm) i5-7200u cpu @ 2.50ghz genuineintel gnulinux '
config_args='-de -Dprefix=/home/fuzzix/perl5/perlbrew/perls/perl-5.40.0 -Aeval:scriptdir=/home/fuzzix/perl5/perlbrew/perls/perl-5.40.0/bin'
hint=recommended
useposix=true
d_sigaction=define
useithreads=undef
usemultiplicity=undef
use64bitint=define
use64bitall=define
uselongdouble=undef
usemymalloc=n
default_inc_excludes_dot=define
Compiler:
cc='cc'
ccflags ='-fwrapv -fno-strict-aliasing -pipe -fstack-protector-strong -I/usr/local/include -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64 -D_FORTIFY_SOURCE=2'
optimize='-O2'
cppflags='-fwrapv -fno-strict-aliasing -pipe -fstack-protector-strong -I/usr/local/include'
ccversion=''
gccversion='13.2.0'
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='cc'
ldflags =' -fstack-protector-strong -L/usr/local/lib'
libpth=/usr/local/lib /usr/lib /lib64 /usr/lib64 /lib /usr/local/lib64
libs=-lpthread -lgdbm -ldb -ldl -lm -lcrypt -lutil -lc -lgdbm_compat
perllibs=-lpthread -ldl -lm -lcrypt -lutil -lc
libc=libc-2.39.so
so=so
useshrplib=false
libperl=libperl.a
gnulibc_version='2.39'
Dynamic Linking:
dlsrc=dl_dlopen.xs
dlext=so
d_dlsymun=undef
ccdlflags='-Wl,-E'
cccdlflags='-fPIC'
lddlflags='-shared -O2 -L/usr/local/lib -fstack-protector-strong'
Characteristics of this binary (from libperl):
Compile-time options:
HAS_LONG_DOUBLE
HAS_STRTOLD
HAS_TIMES
PERLIO_LAYERS
PERL_COPY_ON_WRITE
PERL_DONT_CREATE_GVSV
PERL_HASH_FUNC_SIPHASH13
PERL_HASH_USE_SBOX32
PERL_MALLOC_WRAP
PERL_OP_PARENT
PERL_PRESERVE_IVUV
PERL_USE_SAFE_PUTENV
USE_64_BIT_ALL
USE_64_BIT_INT
USE_LARGE_FILES
USE_LOCALE
USE_LOCALE_COLLATE
USE_LOCALE_CTYPE
USE_LOCALE_NUMERIC
USE_LOCALE_TIME
USE_PERLIO
USE_PERL_ATOF
Built under linux
Compiled at Jun 9 2024 22:36:02
%ENV:
PERLBREW_HOME="/home/fuzzix/.perlbrew"
PERLBREW_MANPATH="/home/fuzzix/perl5/perlbrew/perls/perl-5.40.0/man"
PERLBREW_PATH="/home/fuzzix/perl5/perlbrew/bin:/home/fuzzix/perl5/perlbrew/perls/perl-5.40.0/bin"
PERLBREW_PERL="perl-5.40.0"
PERLBREW_ROOT="/home/fuzzix/perl5/perlbrew"
PERLBREW_SHELLRC_VERSION="0.98"
PERLBREW_VERSION="0.98"
@INC:
/home/fuzzix/perl5/perlbrew/perls/perl-5.40.0/lib/site_perl/5.40.0/x86_64-linux
/home/fuzzix/perl5/perlbrew/perls/perl-5.40.0/lib/site_perl/5.40.0
/home/fuzzix/perl5/perlbrew/perls/perl-5.40.0/lib/5.40.0/x86_64-linux
/home/fuzzix/perl5/perlbrew/perls/perl-5.40.0/lib/5.40.0
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4