Skip to content

ZJIT: zsuper from a method with keyword parameters into a (...) method passes the wrong arguments #1133

Backlog

Description

@thomasklemm

On zjit-headline2 (k0kubun/ruby@f2c3f457ff), an implicit-argument super from a method with keyword parameters into a method defined with (...) raises once ZJIT has profiled the call:

class Base;   def m(*args, **kw) = [args, kw]; end
class Middle < Base; def m(...) = super; end
class Top < Middle;  def m(a, k: nil) = super; end
o = Top.new
100.times { |i| got = o.m(1, k: 2); raise "iteration #{i}: #{got.inspect}" unless got == [[1], {k: 2}] }
puts "ok"

With --zjit or --zjit-call-threshold=2, it raises no implicit conversion of Integer into Hash (TypeError) in Middle#m. The interpreter, --yjit and --zjit-call-threshold=1 print ok, and master 42a644f prints ok in all of these modes. An explicit super(a, k:), or a (*args, **kw) middle method, works.

It bisects to k0kubun/ruby@58b019f6fe ("ZJIT: Specialize zsuper from methods with keyword parameters"); its parent 2d609d3 is good. That commit passes the zsuper's keywords as explicit keywords to an ISEQ callee and doesn't exclude (...) callees. It is also in zjit-headline3.

Active Record's PostgreSQL adapter has this shape: PostgreSQL::DatabaseStatements#insert(..., returning:) calls super, which reaches QueryCache#insert(...). On Discourse's specs (models, lib, serializers, services and jobs), 16,871 of 22,126 examples fail with TypeError: no implicit conversion of Array into Hash.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions