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

feature class: attempting to create an object of an incomplete class asserts #22159

Closed
tonycoz opened this issue Apr 19, 2024 · 2 comments · Fixed by #22166
Closed

feature class: attempting to create an object of an incomplete class asserts #22159

tonycoz opened this issue Apr 19, 2024 · 2 comments · Fixed by #22166

Comments

@tonycoz
Copy link
Contributor

tonycoz commented Apr 19, 2024

Module:

Description

Perl crashes with an assertion (debugging builds) or an unhelpful message (non-debugging) if you attempt to create an object of an incomplete class.

Steps to Reproduce

$ ~/perl/blead/bin/perl5.39.9 -Mfeature=class -e 'eval "class Foo {"; Foo->new'
class is experimental at (eval 1) line 1.
perl5.39.9: class.c:170: injected_constructor: Assertion `aux->xhv_class_initfields_cv' failed.
Aborted

Expected behavior

A helpful error message.

Perl configuration

# perl -V output goes here
Summary of my perl5 (revision 5 version 39 subversion 9) configuration:
  Commit id: bc2427acad39d9b52d84a987047ca10c3c2f7b77
  Platform:
    osname=linux
    osvers=6.1.0-17-amd64
    archname=x86_64-linux
    uname='linux venus 6.1.0-17-amd64 #1 smp preempt_dynamic debian 6.1.69-1 (2023-12-30) x86_64 gnulinux '
    config_args='-des -Dusedevel -DDEBUGGING -Dprefix=/home/tony/perl/blead'
    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 -DDEBUGGING -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 -g'
    cppflags='-fwrapv -DDEBUGGING -fno-strict-aliasing -pipe -fstack-protector-strong -I/usr/local/include'
    ccversion=''
    gccversion='12.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/x86_64-linux-gnu /usr/lib /usr/lib64
    libs=-lpthread -lgdbm -ldl -lm -lcrypt -lutil -lc -lgdbm_compat
    perllibs=-lpthread -ldl -lm -lcrypt -lutil -lc
    libc=/lib/x86_64-linux-gnu/libc.so.6
    so=so
    useshrplib=false
    libperl=libperl.a
    gnulibc_version='2.36'
  Dynamic Linking:
    dlsrc=dl_dlopen.xs
    dlext=so
    d_dlsymun=undef
    ccdlflags='-Wl,-E'
    cccdlflags='-fPIC'
    lddlflags='-shared -O2 -g -L/usr/local/lib -fstack-protector-strong'


Characteristics of this binary (from libperl): 
  Compile-time options:
    DEBUGGING
    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_DEVEL
    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 Mar  4 2024 11:01:24
  %ENV:
    PERLBREW_BASHRC_VERSION="0.43"
    PERLBREW_HOME="/home/tony/.perlbrew"
    PERLBREW_MANPATH=""
    PERLBREW_PATH="/home/tony/perl5/perlbrew/bin"
    PERLBREW_ROOT="/home/tony/perl5/perlbrew"
    PERLBREW_VERSION="0.67"
  @INC:
    /home/tony/perl/blead/lib/site_perl/5.39.9/x86_64-linux
    /home/tony/perl/blead/lib/site_perl/5.39.9
    /home/tony/perl/blead/lib/5.39.9/x86_64-linux
    /home/tony/perl/blead/lib/5.39.9

@jkeenan
Copy link
Contributor

jkeenan commented Apr 20, 2024

Perl crashes with an assertion (debugging builds) or an unhelpful message (non-debugging) if you attempt to create an object of an incomplete class.

Is this the "unhelpful message" you get in non-debugging builds?

$ ./bin/perl -Ilib -Mfeature=class -e 'eval "class Foo {"; Foo->new'
class is experimental at (eval 1) line 1.
Not a CODE reference at -e line 1.

(From a non-debugging build of perl-5.39.5 on Linux; similar output at today's HEAD on blead.)

@jkeenan
Copy link
Contributor

jkeenan commented Apr 21, 2024

The "unhelpful" error message on regular build, as well as the crash on debugging build, appear to have first appeared at commit 080297a back in September.

$ git show --format=fuller 080297a1c0
commit 080297a1c054c421f95cf78ca4f58a960f1d124f
Author:     Tony Cook <tony@develop-help.com>
AuthorDate: Tue Sep 5 16:37:48 2023 +1000
Commit:     Tony Cook <tony@develop-help.com>
CommitDate: Fri Sep 15 09:10:37 2023 +1000

    class: don't leak the default initialiser ops if they're forbidden
...

$  uname -mrs; gcc --version | head -n 1
Linux 6.5.0-27-generic x86_64
gcc (Ubuntu 11.4.0-1ubuntu1~22.04) 11.4.0

$ sh ./Configure -des -Dusedevel -Dcc=gcc && make

$ git describe
v5.39.2-120-g37f50f0f03
$ ./perl -Ilib -Mfeature=class -e 'eval "class Foo {"; Foo->new'
class is experimental at (eval 1) line 1.
Undefined subroutine called at -e line 1.

$ git describe; ./perl -Ilib -Mfeature=class -e 'eval "class Foo {"; Foo->new'
v5.39.2-121-g080297a1c0
class is experimental at (eval 1) line 1.
Not a CODE reference at -e line 1.


$ sh ./Configure -des -Dusedevel -Dcc=gcc -DDEBUGGING && make

$ git describe; ./perl -Ilib -Mfeature=class -e 'eval "class Foo {"; Foo->new'
v5.39.2-120-g37f50f0f03
class is experimental at (eval 1) line 1.
Undefined subroutine called at -e line 1.

$ git describe; ./perl -Ilib -Mfeature=class -e 'eval "class Foo {"; Foo->new'
v5.39.2-121-g080297a1c0
class is experimental at (eval 1) line 1.
perl: class.c:170: injected_constructor: Assertion `aux->xhv_class_initfields_cv' failed.
Aborted (core dumped)

I think this qualifies as a Release Blocker; so labeling.

jkeenan added a commit to jkeenan/devel-git-multibisect that referenced this issue Apr 21, 2024
Devel::Git::MultiBisect::set_targets() has heretofore assumed that any
file to be tested sits in the same directory tree as the source code
being run for bisection.  The top-level directory has been automatically
prepended to the lower part of the test file's path.

But in order to get a handle on Perl/perl5#22159, I had to add a test to a test file and have it run in the same way on each commit.  As a temporary bandaid, I hacked set_targets() to enable that.  This should be revisited.
tonycoz added a commit to tonycoz/perl5 that referenced this issue Apr 23, 2024
tonycoz added a commit to tonycoz/perl5 that referenced this issue Apr 23, 2024
tonycoz added a commit to tonycoz/perl5 that referenced this issue Apr 23, 2024
and briefly document the undocumented messages it found.

Note that the "Odd number of arguments" message isn't suppressible,
I do not know if that is by design:

  $ ./perl -Ilib -Mfeature=class -e 'no warnings; class C { field $x:param; } C->new("x")'
  Odd number of arguments passed to "C" constructor at -e line 1.

Discovered when porting/diag.t didn't warn about my new message
in the fix for Perl#22159
tonycoz added a commit that referenced this issue Apr 23, 2024
tonycoz added a commit that referenced this issue Apr 23, 2024
and briefly document the undocumented messages it found.

Note that the "Odd number of arguments" message isn't suppressible,
I do not know if that is by design:

  $ ./perl -Ilib -Mfeature=class -e 'no warnings; class C { field $x:param; } C->new("x")'
  Odd number of arguments passed to "C" constructor at -e line 1.

Discovered when porting/diag.t didn't warn about my new message
in the fix for #22159
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants