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

Segfaults when inheriting from empty class #21221

Open
Ovid opened this issue Jul 9, 2023 · 7 comments
Open

Segfaults when inheriting from empty class #21221

Ovid opened this issue Jul 9, 2023 · 7 comments
Labels

Comments

@Ovid
Copy link
Contributor

Ovid commented Jul 9, 2023

Description

When using the experimental class syntax in v5.38.0, we segfault if we inherit from an empty base class.

Steps to Reproduce

perl -E 'use experimental "class"; class Animal; class Dog  :isa(Animal); say "Hello"'
Segmentation fault: 11

Defining the body of the Animal class makes the error go away.

perl -E 'use experimental "class"; class Animal {}; class Dog  :isa(Animal); say "Hello"'
Hello

Expected behavior

I would have expected the code above to print "Hello"

Perl configuration

Summary of my perl5 (revision 5 version 38 subversion 0) configuration:
   
  Platform:
    osname=darwin
    osvers=22.5.0
    archname=darwin-2level
    uname='darwin ovids-m1-laptop.local 22.5.0 darwin kernel version 22.5.0: thu jun 8 22:22:20 pdt 2023; root:xnu-8796.121.3~7release_arm64_t6000 arm64 '
    config_args='-de -Dprefix=/Users/ovid/perl5/perlbrew/perls/perl-5.38.0 -Aeval:scriptdir=/Users/ovid/perl5/perlbrew/perls/perl-5.38.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 ='-fno-common -DPERL_DARWIN -mmacosx-version-min=13.4 -DNO_POSIX_2008_LOCALE -fno-strict-aliasing -pipe -fstack-protector-strong -I/usr/local/include -I/opt/local/include'
    optimize='-O3'
    cppflags='-fno-common -DPERL_DARWIN -mmacosx-version-min=13.4 -DNO_POSIX_2008_LOCALE -fno-strict-aliasing -pipe -fstack-protector-strong -I/usr/local/include -I/opt/local/include'
    ccversion=''
    gccversion='Apple LLVM 14.0.3 (clang-1403.0.22.14.1)'
    gccosandvers=''
    intsize=4
    longsize=8
    ptrsize=8
    doublesize=8
    byteorder=12345678
    doublekind=3
    d_longlong=define
    longlongsize=8
    d_longdbl=define
    longdblsize=8
    longdblkind=0
    ivtype='long'
    ivsize=8
    nvtype='double'
    nvsize=8
    Off_t='off_t'
    lseeksize=8
    alignbytes=8
    prototype=define
  Linker and Libraries:
    ld='cc'
    ldflags =' -mmacosx-version-min=13.4 -fstack-protector-strong -L/usr/local/lib -L/opt/local/lib'
    libpth=/usr/local/lib /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/clang/14.0.3/lib /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/lib /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib /opt/local/lib /usr/lib
    libs= 
    perllibs=
    libc=
    so=dylib
    useshrplib=false
    libperl=libperl.a
    gnulibc_version=''
  Dynamic Linking:
    dlsrc=dl_dlopen.xs
    dlext=bundle
    d_dlsymun=undef
    ccdlflags=' '
    cccdlflags=' '
    lddlflags=' -mmacosx-version-min=13.4 -bundle -undefined dynamic_lookup -L/usr/local/lib -L/opt/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 darwin
  Compiled at Jul  4 2023 08:24:13
  %ENV:
    PERL5LIB="/Users/ovid/veure/t/tests:/Users/ovid/veure/t/shared:/Users/ovid/veure/t/admin:/Users/ovid/perlcustom/lib"
    PERLBREW_HOME="/Users/ovid/.perlbrew"
    PERLBREW_MANPATH="/Users/ovid/perl5/perlbrew/perls/perl-5.38.0/man"
    PERLBREW_PATH="/Users/ovid/perl5/perlbrew/bin:/Users/ovid/perl5/perlbrew/perls/perl-5.38.0/bin"
    PERLBREW_PERL="perl-5.38.0"
    PERLBREW_ROOT="/Users/ovid/perl5/perlbrew"
    PERLBREW_SHELLRC_VERSION="0.96"
    PERLBREW_VERSION="0.96"
  @INC:
    /Users/ovid/veure/t/tests
    /Users/ovid/veure/t/shared
    /Users/ovid/veure/t/admin
    /Users/ovid/perlcustom/lib
    /Users/ovid/perl5/perlbrew/perls/perl-5.38.0/lib/site_perl/5.38.0/darwin-2level
    /Users/ovid/perl5/perlbrew/perls/perl-5.38.0/lib/site_perl/5.38.0
    /Users/ovid/perl5/perlbrew/perls/perl-5.38.0/lib/5.38.0/darwin-2level
    /Users/ovid/perl5/perlbrew/perls/perl-5.38.0/lib/5.38.0
@johannessen
Copy link
Contributor

Possibly related: #20890

@johannessen
Copy link
Contributor

Just remembered the PSC #102 summary, according to which this should have been documented as a known bug. But I’m afraid we all kind of forgot about that. 😑

@bscan
Copy link

bscan commented Jul 9, 2023

  • The segfaults on feature-class and refaliasing won't be fixed before 5.38, and should just be documented as "known bugs"

Which segfaults are known, and which are new bugs? I'm also seeing a segfault with this:

class Point {
    field $x: param();
}

@johannessen
Copy link
Contributor

I think that one may be new?

Searching for “class” in the issues here, I see two more – #20947 and #20956.

@jkeenan
Copy link
Contributor

jkeenan commented Jul 10, 2023

Description

When using the experimental class syntax in v5.38.0, we segfault if we inherit from an empty base class.
[snip]

Defining the body of the Animal class makes the error go away.

perl -E 'use experimental "class"; class Animal {}; class Dog  :isa(Animal); say "Hello"'
Hello

Providing a body for at least one of the class definitions appears to avoid the segfault.

$ perl -v | head -2 | tail -1
This is perl 5, version 38, subversion 0 (v5.38.0) built for x86_64-linux

$ perl -E 'use experimental "class"; class Animal; class Dog {}; say "Hello"'
Hello

$ perl -E 'use experimental "class"; class Animal; class Dog; class Entity {}; say "Hello"'
Hello

$ perl -E 'use experimental "class"; class Entity; class Dog {}; class Animal; say "Hello"'
Hello

@jkeenan jkeenan added Bug and removed Needs Triage labels Jul 10, 2023
@Ovid
Copy link
Contributor Author

Ovid commented Jul 10, 2023

Yes, this does look like a duplicate of #20890. Sorry for that.

@leonerd
Copy link
Contributor

leonerd commented Feb 29, 2024

Still seems to fail on current bleadperl:

$ ./perl -Ilib -E 'use experimental "class"; class Animal; class Dog  :isa(Animal); say "Hello"'
perl: op.c:7737: Perl_newSVOP: Assertion `sv' failed.
Aborted

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

No branches or pull requests

5 participants