Skip to content

Dynamic dispatch to super.initialize_[dup,clone] in native Set#6910

Merged
headius merged 2 commits intojruby:jruby-9.2from
headius:init_dup_set_super
Oct 26, 2021
Merged

Dynamic dispatch to super.initialize_[dup,clone] in native Set#6910
headius merged 2 commits intojruby:jruby-9.2from
headius:init_dup_set_super

Conversation

@headius
Copy link
Member

@headius headius commented Oct 26, 2021

Fixes #6903

@headius headius added this to the JRuby 9.2.20.0 milestone Oct 26, 2021
@headius headius force-pushed the init_dup_set_super branch from b8710b9 to 0146b21 Compare October 26, 2021 16:55
@headius headius merged commit 567bdea into jruby:jruby-9.2 Oct 26, 2021
@headius headius deleted the init_dup_set_super branch October 26, 2021 17:11
headius added a commit to headius/jruby that referenced this pull request Dec 3, 2021
We can't blindly get the current object's class's superclass
because the object's class may be multiple descendants below the
Set class, causing super calls to super back into a lower point
in the hierarchy. This is the cause of jruby#6958.

The fix here is to request a frame be pushed for Set#init_dup and
init_clone so that we can redispatch from the proper point in the
hierarchy. This also properly uses SuperCallSite, passing in the
class from which to super. The original code was flawed in two
ways:

* It always acquired the superclass via object.class.superclass,
  which does not work for a two-deep descendant of Set.
* It passed the superclass in for the frame class, which allowed
  the flawed logic to work for one level deep. It is broken for
  two levels deep or no levels deep because it passes the wrong
  frame class.

This was not found during testing of jruby#6910 because the original
example only has one descendant.
headius added a commit to headius/jruby that referenced this pull request Dec 3, 2021
We can't blindly get the current object's class's superclass
because the object's class may be multiple descendants below the
Set class, causing super calls to super back into a lower point
in the hierarchy. This is the cause of jruby#6958.

The fix here is to request a frame be pushed for Set#init_dup and
init_clone so that we can redispatch from the proper point in the
hierarchy. This also properly uses SuperCallSite, passing in the
class from which to super. The original code was flawed in two
ways:

* It always acquired the superclass via object.class.superclass,
  which does not work for a two-deep descendant of Set.
* It passed the superclass in for the frame class, which allowed
  the flawed logic to work for one level deep. It is broken for
  two levels deep or no levels deep because it passes the wrong
  frame class.

This was not found during testing of jruby#6910 because the original
example only has one descendant.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant