Project

General

Profile

Actions

Bug #22562

open

Type confusion SEGV: Using `super`, `instance_exec`, and `bind_call`, it is possible to run Array#first on an instance of Integer

Bug #22562: Type confusion SEGV: Using `super`, `instance_exec`, and `bind_call`, it is possible to run Array#first on an instance of Integer

Added by alanwu (Alan Wu) about 11 hours ago. Updated about 11 hours ago.

Status:
Open
Assignee:
-
Target version:
-
[ruby-core:127562]

Description

The following crashes 3.3.0 through current trunk (caf4f279d1):

module M
  # fixnum: (0x6f56<<1)+1 = 0xdead
  def first = 0x6f56.instance_exec { super }
end
M.instance_method(:first).bind_call([])
# <internal:array>:132: [BUG] Segmentation fault at 0x000000000000dead

Generally, the body of methods don't type-check self, relying on method dispatch to uphold the is-a relationship between self and the class/module defining the method. This funky use of super breaks that invariant.


Related issues 1 (0 open — 1 closed)

Related to Ruby - Feature #4254: Allow method transplantingClosedmatz (Yukihiro Matsumoto)Actions

Updated by alanwu (Alan Wu) about 11 hours ago Actions #1

  • Subject changed from Type confusion SEGV: Using `super`, `instance_exec`, and `bind_call`, it is possible to run Array#first method on an instance of Integer to Type confusion SEGV: Using `super`, `instance_exec`, and `bind_call`, it is possible to run Array#first on an instance of Integer

Updated by alanwu (Alan Wu) about 10 hours ago Actions #2

Actions

Also available in: PDF Atom