[Perl/perl5] 94e539: Defer seal of subclass until superclass is done

[email protected] (Paul Evans via perl5-changes)
Newsgroups perl.perl5.changes
Message-ID <Perl/perl5/push/refs/heads/blead/[email protected]>
  Branch: refs/heads/blead
  Home:   https://github.com/Perl/perl5
  Commit: 94e539065d94fbbf604cff345c786d952c08d6b1
      https://github.com/Perl/perl5/commit/94e539065d94fbbf604cff345c786d952c08d6b1
  Author: Paul "LeoNerd" Evans <[email protected]>
  Date:   2026-03-26 (Thu, 26 Mar 2026)

  Changed paths:
    M class.c
    M hv.h
    M regen/embed.pl
    M t/class/inherit.t

  Log Message:
  -----------
  Defer seal of subclass until superclass is done

Fixes https://github.com/Perl/perl5/issues/20890

The bug is that when you seal class that is a subclass of an existing one,
if that existing one was not yet sealed then a pointer access hasn't yet
been filled in, and a NULL deref occurs.

This is fixed by a reïmplementation of the same deferral logic that
Object::Pad has found to be good and stable. Namely, that each class
needs a flag that tracks whether it has been sealed. When attempting to
seal a class whose superclass isn't yet sealed, we defer the operation
until the superclass is sealed, instead just making a note within the
superclass that it should come back and seal this one later.

This deferral mechanism allows a variety of subclassing cases to work
which previously did not. As well as the original case described in
GH#20890, this also permits block-scoped sub-classes defined inside the
base class's scope. Such syntax may be useful for a new ability in
future.



To unsubscribe from these emails, change your notification settings at https://github.com/Perl/perl5/settings/notifications
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.