Closed JoshCheek closed 7 years ago
require 'fiddle' class Object def pop_class selfptr = Fiddle::Pointer[__id__*2] classptr = (selfptr+8).ptr selfptr[8, 8] = classptr[16, 8] classptr.to_value end end C1 = Class.new { def head() :C1_superclass_of_C2 end } C2 = Class.new(C1) { def head() :C2_original_class end } M1 = Module.new { def head() :class_that_includes_mod1_into_C2 end } C2.include(M1) M2 = Module.new { def head() :class_that_includes_mod2_into_singleton end } list = C2.new.extend(M2) list.instance_eval { def head() :singleton_class end } Fiddle::Pointer[list.__id__*2].+(8).ptr.+(536).ptr.to_value # => # 584 list.singleton_class.ancestors # => list.head # => list.pop_class # => list.head # => list.pop_class # => list.head # => list.pop_class # => list.head # => list.pop_class # => list.head # => list.pop_class # => list.head # => # !> /Users/josh/.gem/ruby/2.3.1/gems/seeing_is_believing-3.1.0/lib/seeing_is_believing/event_stream/producer.rb:54: [BUG] Segmentation fault at 0x00000000000018 # !> ruby 2.3.1p112 (2016-04-26 revision 54768) [x86_64-darwin15] # !> # !> -- Crash Report log information -------------------------------------------- # !> See Crash Report log file under the one of following: # !> * ~/Library/Logs/CrashReporter # !> * /Library/Logs/CrashReporter # !> * ~/Library/Logs/DiagnosticReports # !> * /Library/Logs/DiagnosticReports # !> for more details. # !> Don't forget to include the above Crash Report log file in bug reports. # !> # !> -- Control frame information ----------------------------------------------- # !> c:0003 p:0122 s:0015 e:000013 METHOD /Users/josh/.gem/ruby/2.3.1/gems/seeing_is_believing-3.1.0/lib/seeing_is_believing/event_stream/producer.rb:54 # !> c:0002 p:0199 s:0005 E:000de8 EVAL /var/folders/7g/mbft22555w3_2nqs_h1kbglw0000gn/T/seeing_is_believing_temp_dir20161224-17706-nwssph/program.rb:19 [FINISH] # !> c:0001 p:0000 s:0002 E:0022a0 (none) [FINISH] # !> # !> -- Ruby level backtrace information ---------------------------------------- # !> /var/folders/7g/mbft22555w3_2nqs_h1kbglw0000gn/T/seeing_is_believing_temp_dir20161224-17706-nwssph/program.rb:19:in `<main>' # !> /Users/josh/.gem/ruby/2.3.1/gems/seeing_is_believing-3.1.0/lib/seeing_is_believing/event_stream/producer.rb:54:in `record_result' # !> # !> -- Machine register context ------------------------------------------------ # !> rax: 0x0000000000000000 rbx: 0x0000000000000ab1 rcx: 0x00007fe2740d4c00 # !> rdx: 0x00000000000002b1 rdi: 0x0000000000000000 rsi: 0x0000000000000000 # !> rbp: 0x00007fff55cedf30 rsp: 0x00007fff55cedef0 r8: 0x00007fe275006db8 # !> r9: 0x00007fe273c06e10 r10: 0x00007fff55cee210 r11: 0x0000000000000000 # !> r12: 0x0000000000000ab1 r13: 0x0000000000000000 r14: 0x00007fe273c06e10 # !> r15: 0x0000000000000ab1 rip: 0x000000010a0a2bf5 rfl: 0x0000000000010206 # !> # !> -- C level backtrace information ------------------------------------------- # !> 0 ruby 0x000000010a0bab84 rb_vm_bugreport + 388 # !> 1 ruby 0x0000000109f557ea rb_bug_context + 490 # !> 2 ruby 0x000000010a02af64 sigsegv + 68 # !> 3 libsystem_platform.dylib 0x00007fff945e652a _sigtramp + 26 # !> 4 ruby 0x000000010a0a2bf5 method_entry_get + 229 # !> 5 ??? 0x00007fff55cedf40 0x0 + 140734633008960 # !> # !> -- Other runtime information ----------------------------------------------- # !> # !> * Loaded script: /var/folders/7g/mbft22555w3_2nqs_h1kbglw0000gn/T/seeing_is_believing_temp_dir20161224-17706-nwssph/program.rb # !> # !> * Loaded features: # !> # !> 0 enumerator.so # !> 1 thread.rb # !> 2 rational.so # !> 3 complex.so # !> 4 /Users/josh/.rubies/ruby-2.3.1/lib/ruby/2.3.0/x86_64-darwin15/enc/encdb.bundle # !> 5 /Users/josh/.rubies/ruby-2.3.1/lib/ruby/2.3.0/x86_64-darwin15/enc/trans/transdb.bundle # !> 6 /Users/josh/.rubies/ruby-2.3.1/lib/ruby/2.3.0/unicode_normalize.rb # !> 7 /Users/josh/.rubies/ruby-2.3.1/lib/ruby/2.3.0/x86_64-darwin15/rbconfig.rb # !> 8 /Users/josh/.rubies/ruby-2.3.1/lib/ruby/site_ruby/2.3.0/rubygems/compatibility.rb # !> 9 /Users/josh/.rubies/ruby-2.3.1/lib/ruby/site_ruby/2.3.0/rubygems/defaults.rb # !> 10 /Users/josh/.rubies/ruby-2.3.1/lib/ruby/site_ruby/2.3.0/rubygems/deprecate.rb # !> 11 /Users/josh/.rubies/ruby-2.3.1/lib/ruby/site_ruby/2.3.0/rubygems/errors.rb # !> 12 /Users/josh/.rubies/ruby-2.3.1/lib/ruby/site_ruby/2.3.0/rubygems/version.rb # !> 13 /Users/josh/.rubies/ruby-2.3.1/lib/ruby/site_ruby/2.3.0/rubygems/requirement.rb # !> 14 /Users/josh/.rubies/ruby-2.3.1/lib/ruby/site_ruby/2.3.0/rubygems/platform.rb # !> 15 /Users/josh/.rubies/ruby-2.3.1/lib/ruby/site_ruby/2.3.0/rubygems/basic_specification.rb # !> 16 /Users/josh/.rubies/ruby-2.3.1/lib/ruby/site_ruby/2.3.0/rubygems/stub_specification.rb # !> 17 /Users/josh/.rubies/ruby-2.3.1/lib/ruby/site_ruby/2.3.0/rubygems/util/list.rb # !> 18 /Users/josh/.rubies/ruby-2.3.1/lib/ruby/2.3.0/x86_64-darwin15/stringio.bundle # !> 19 /Users/josh/.rubies/ruby-2.3.1/lib/ruby/site_ruby/2.3.0/rubygems/specification.rb # !> 20 /Users/josh/.rubies/ruby-2.3.1/lib/ruby/site_ruby/2.3.0/rubygems/exceptions.rb # !> 21 /Users/josh/.rubies/ruby-2.3.1/lib/ruby/site_ruby/2.3.0/rubygems/core_ext/kernel_gem.rb # !> 22 /Users/josh/.rubies/ruby-2.3.1/lib/ruby/2.3.0/monitor.rb # !> 23 /Users/josh/.rubies/ruby-2.3.1/lib/ruby/site_ruby/2.3.0/rubygems/core_ext/kernel_require.rb # !> 24 /Users/josh/.rubies/ruby-2.3.1/lib/ruby/site_ruby/2.3.0/rubygems.rb # !> 25 /Users/josh/.rubies/ruby-2.3.1/lib/ruby/site_ruby/2.3.0/rubygems/path_support.rb # !> 26 /Users/josh/.rubies/ruby-2.3.1/lib/ruby/site_ruby/2.3.0/rubygems/dependency.rb # !> 27 /Users/josh/.rubies/ruby-2.3.1/lib/ruby/gems/2.3.0/gems/did_you_mean-1.0.0/lib/did_you_mean/version.rb # !> 28 /Users/josh/.rubies/ruby-2.3.1/lib/ruby/gems/2.3.0/gems/did_you_mean-1.0.0/lib/did_you_mean/core_ext/name_error.rb # !> 29 /Users/josh/.rubies/ruby-2.3.1/lib/ruby/gems/2.3.0/gems/did_you_mean-1.0.0/lib/did_you_mean/levenshtein.rb # !> 30 /Users/josh/.rubies/ruby-2.3.1/lib/ruby/gems/2.3.0/gems/did_you_mean-1.0.0/lib/did_you_mean/jaro_winkler.rb # !> 31 /Users/josh/.rubies/ruby-2.3.1/lib/ruby/gems/2.3.0/gems/did_you_mean-1.0.0/lib/did_you_mean/spell_checkable.rb # !> 32 /Users/josh/.rubies/ruby-2.3.1/lib/ruby/2.3.0/delegate.rb # !> 33 /Users/josh/.rubies/ruby-2.3.1/lib/ruby/gems/2.3.0/gems/did_you_mean-1.0.0/lib/did_you_mean/spell_checkers/name_error_checkers/class_name_checker.rb # !> 34 /Users/josh/.rubies/ruby-2.3.1/lib/ruby/gems/2.3.0/gems/did_you_mean-1.0.0/lib/did_you_mean/spell_checkers/name_error_checkers/variable_name_checker.rb # !> 35 /Users/josh/.rubies/ruby-2.3.1/lib/ruby/gems/2.3.0/gems/did_you_mean-1.0.0/lib/did_you_mean/spell_checkers/name_error_checkers.rb # !> 36 /Users/josh/.rubies/ruby-2.3.1/lib/ruby/gems/2.3.0/gems/did_you_mean-1.0.0/lib/did_you_mean/spell_checkers/method_name_checker.rb # !> 37 /Users/josh/.rubies/ruby-2.3.1/lib/ruby/gems/2.3.0/gems/did_you_mean-1.0.0/lib/did_you_mean/spell_checkers/null_checker.rb # !> 38 /Users/josh/.rubies/ruby-2.3.1/lib/ruby/gems/2.3.0/gems/did_you_mean-1.0.0/lib/did_you_mean/formatter.rb # !> 39 /Users/josh/.rubies/ruby-2.3.1/lib/ruby/gems/2.3.0/gems/did_you_mean-1.0.0/lib/did_you_mean.rb # !> 40 /Users/josh/.gem/ruby/2.3.1/gems/seeing_is_believing-3.1.0/lib/seeing_is_believing/safe.rb # !> 41 /Users/josh/.gem/ruby/2.3.1/gems/seeing_is_believing-3.1.0/lib/seeing_is_believing/version.rb # !> 42 /Users/josh/.gem/ruby/2.3.1/gems/seeing_is_believing-3.1.0/lib/seeing_is_believing/hash_struct.rb # !> 43 /Users/josh/.gem/ruby/2.3.1/gems/seeing_is_believing-3.1.0/lib/seeing_is_believing/event_stream/events.rb # !> 44 /Users/josh/.gem/ruby/2.3.1/gems/seeing_is_believing-3.1.0/lib/seeing_is_believing/event_stream/producer.rb # !> 45 /Users/josh/.gem/ruby/2.3.1/gems/seeing_is_believing-3.1.0/lib/seeing_is_believing/the_matrix.rb # !> 46 /Users/josh/.rubies/ruby-2.3.1/lib/ruby/2.3.0/prettyprint.rb # !> 47 /Users/josh/.rubies/ruby-2.3.1/lib/ruby/2.3.0/pp.rb # !> 48 /Users/josh/.gem/ruby/2.3.1/gems/seeing_is_believing-3.1.0/lib/seeing_is_believing/customize_pp.rb # !> 49 /Users/josh/.rubies/ruby-2.3.1/lib/ruby/2.3.0/x86_64-darwin15/fiddle.bundle # !> 50 /Users/josh/.rubies/ruby-2.3.1/lib/ruby/2.3.0/fiddle/function.rb # !> 51 /Users/josh/.rubies/ruby-2.3.1/lib/ruby/2.3.0/fiddle/closure.rb # !> 52 /Users/josh/.rubies/ruby-2.3.1/lib/ruby/2.3.0/fiddle.rb # !> # !> [NOTE] # !> You may have encountered a bug in the Ruby interpreter or extension libraries. # !> Bug reports are welcome. # !> For details: http://www.ruby-lang.org/bugreport.html # !> __END__ o.m ptr = Fiddle::Pointer[o.__id__*2] ptr[8, 8] = ptr.+(8).ptr[0, 8] o.m o = C.new ptr = Fiddle::Pointer.new( C.object_id * 2 ) ptr.to_value [C.object_id * 2].pack('Q') ptr .ref .ref .ref .ptr .ptr .ptr # ~> NoMethodError # ~> undefined method `use' for main:Object # ~> # ~> /var/folders/7g/mbft22555w3_2nqs_h1kbglw0000gn/T/seeing_is_believing_temp_dir20161224-16046-1bgqgf2/program.rb:2:in `<main>'/Users/josh/.gem/ruby/2.3.1/gems/seeing_is_believing-3.1.0/lib/seeing_is_believing/binary.rb:61:in `call': undefined method `zero?' for nil:NilClass (NoMethodError) from /Users/josh/.gem/ruby/2.3.1/gems/seeing_is_believing-3.1.0/bin/seeing_is_believing:6:in `<top (required)>' from /Users/josh/.gem/ruby/2.3.1/bin/seeing_is_believing:22:in `load' from /Users/josh/.gem/ruby/2.3.1/bin/seeing_is_believing:22:in `<main>' /Users/josh/.gem/ruby/2.3.1/gems/seeing_is_believing-3.1.0/lib/seeing_is_believing/binary.rb:61:in `call': undefined method `zero?' for nil:NilClass (NoMethodError) from /Users/josh/.gem/ruby/2.3.1/gems/seeing_is_believing-3.1.0/bin/seeing_is_believing:6:in `<top (required)>' from /Users/josh/.gem/ruby/2.3.1/bin/seeing_is_believing:22:in `load' from /Users/josh/.gem/ruby/2.3.1/bin/seeing_is_believing:22:in `<main>' /Users/josh/.gem/ruby/2.3.1/gems/seeing_is_believing-3.1.0/lib/seeing_is_believing/binary.rb:61:in `call': undefined method `zero?' for nil:NilClass (NoMethodError) from /Users/josh/.gem/ruby/2.3.1/gems/seeing_is_believing-3.1.0/bin/seeing_is_believing:6:in `<top (required)>' from /Users/josh/.gem/ruby/2.3.1/bin/seeing_is_believing:22:in `load' from /Users/josh/.gem/ruby/2.3.1/bin/seeing_is_believing:22:in `<main>' /Users/josh/.gem/ruby/2.3.1/gems/seeing_is_believing-3.1.0/lib/seeing_is_believing/binary.rb:61:in `call': undefined method `zero?' for nil:NilClass (NoMethodError) from /Users/josh/.gem/ruby/2.3.1/gems/seeing_is_believing-3.1.0/bin/seeing_is_believing:6:in `<top (required)>' from /Users/josh/.gem/ruby/2.3.1/bin/seeing_is_believing:22:in `load' from /Users/josh/.gem/ruby/2.3.1/bin/seeing_is_believing:22:in `<main>'