ConradIrwin / interception

Listen to raise in ruby
MIT License
24 stars 5 forks source link

Segmentation fault on any error while using pry-rescue #23

Open ferdynton opened 6 years ago

ferdynton commented 6 years ago

Hi! We just hit this segmentation fault in our Rails app (a pretty large one BTW) and I wanted to let you know. Running any code that generates an exception on a Rails console triggers the segfault. Doing so on a normal irb session after loading pry-rescue does not.

While I do understand there might be a million of causes for this issues and I'm not providing enough context, I wanted to report this regardless. Please let me know what other information I can provide to help with the debugging.

The Ruby version is 2.3.4, the Rails version is 4.2.8 and it's confirmed to happen with pry-rescue 1.4.2 through 1.4.5. I'm running a MacBook Pro with Sierra 10.12.5. Removing pry-rescue eliminates the issue.

[1] pry(main)> [:a].map(&:name)
/Users/user/Code/codebase/vendor/bundle/ruby/2.3.0/gems/interception-0.5/lib/cross_platform.rb:68: [BUG] Segmentation fault at 0x00000108cbd028
ruby 2.3.4p301 (2017-03-30 revision 58214) [x86_64-darwin14]

-- 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:0030 p:---- s:0115 e:000114 CFUNC  :binding
c:0029 p:0015 s:0112 e:000109 BLOCK  /Users/user/Code/codebase/vendor/bundle/ruby/2.3.0/gems/interception-0.5/lib/cross_platform.rb:68 [FINISH]
c:0028 p:---- s:0107 e:000106 IFUNC  :name
c:0027 p:---- s:0105 e:000104 CFUNC  :map
c:0026 p:0010 s:0102 E:001270 EVAL   (pry):1 [FINISH]
c:0025 p:---- s:0100 e:000099 CFUNC  :eval
c:0024 p:0052 s:0094 E:0012e0 METHOD /Users/user/Code/codebase/vendor/bundle/ruby/2.3.0/gems/pry-0.11.3/lib/pry/pry_instance.rb:355
c:0023 p:0296 s:0089 E:001378 METHOD /Users/user/Code/codebase/vendor/bundle/ruby/2.3.0/gems/pry-0.11.3/lib/pry/pry_instance.rb:323
c:0022 p:0014 s:0079 E:001480 BLOCK  /Users/user/Code/codebase/vendor/bundle/ruby/2.3.0/gems/pry-0.11.3/lib/pry/pry_instance.rb:243 [FINISH]
c:0021 p:---- s:0077 e:000076 CFUNC  :catch
c:0020 p:0011 s:0073 E:001440 BLOCK  /Users/user/Code/codebase/vendor/bundle/ruby/2.3.0/gems/pry-0.11.3/lib/pry/pry_instance.rb:242 [FINISH]
c:0019 p:---- s:0071 e:000070 CFUNC  :catch
c:0018 p:0034 s:0067 E:001400 METHOD /Users/user/Code/codebase/vendor/bundle/ruby/2.3.0/gems/pry-0.11.3/lib/pry/pry_instance.rb:241
c:0017 p:0069 s:0060 E:000fc8 BLOCK  /Users/user/Code/codebase/vendor/bundle/ruby/2.3.0/gems/pry-0.11.3/lib/pry/repl.rb:77 [FINISH]
c:0016 p:---- s:0057 e:000056 CFUNC  :loop
c:0015 p:0009 s:0054 E:001070 METHOD /Users/user/Code/codebase/vendor/bundle/ruby/2.3.0/gems/pry-0.11.3/lib/pry/repl.rb:67
c:0014 p:0008 s:0051 E:001010 BLOCK  /Users/user/Code/codebase/vendor/bundle/ruby/2.3.0/gems/pry-0.11.3/lib/pry/repl.rb:38 [FINISH]
c:0013 p:0019 s:0049 E:001058 METHOD /Users/user/Code/codebase/vendor/bundle/ruby/2.3.0/gems/pry-0.11.3/lib/pry/input_lock.rb:61
c:0012 p:0033 s:0045 E:002090 METHOD /Users/user/Code/codebase/vendor/bundle/ruby/2.3.0/gems/pry-0.11.3/lib/pry/input_lock.rb:79
c:0011 p:0029 s:0040 E:002340 METHOD /Users/user/Code/codebase/vendor/bundle/ruby/2.3.0/gems/pry-0.11.3/lib/pry/repl.rb:38
c:0010 p:0023 s:0037 E:001a58 METHOD /Users/user/Code/codebase/vendor/bundle/ruby/2.3.0/gems/pry-0.11.3/lib/pry/repl.rb:13
c:0009 p:0240 s:0033 E:000058 METHOD /Users/user/Code/codebase/vendor/bundle/ruby/2.3.0/gems/pry-0.11.3/lib/pry/pry_class.rb:192
c:0008 p:0191 s:0027 E:001310 METHOD /Users/user/Code/codebase/vendor/bundle/ruby/2.3.0/gems/railties-4.2.8/lib/rails/commands/console.rb:110
c:0007 p:0015 s:0024 E:001598 METHOD /Users/user/Code/codebase/vendor/bundle/ruby/2.3.0/gems/railties-4.2.8/lib/rails/commands/console.rb:9
c:0006 p:0101 s:0020 E:000c48 METHOD /Users/user/Code/codebase/vendor/bundle/ruby/2.3.0/gems/railties-4.2.8/lib/rails/commands/commands_tasks.rb:68
c:0005 p:0036 s:0016 E:000c98 METHOD /Users/user/Code/codebase/vendor/bundle/ruby/2.3.0/gems/railties-4.2.8/lib/rails/commands/commands_tasks.rb:39
c:0004 p:0123 s:0012 E:000cf0 TOP    /Users/user/Code/codebase/vendor/bundle/ruby/2.3.0/gems/railties-4.2.8/lib/rails/commands.rb:17 [FINISH]
c:0003 p:---- s:0008 e:000007 CFUNC  :require
c:0002 p:0049 s:0004 E:000b30 EVAL   bin/rails:6 [FINISH]
ConradIrwin commented 6 years ago

Hi Fernando. I'm sorry about this! The problem is likely with the C-extension used by interception (which powers pry-rescue).

I haven't done much work on either project in a few years. Definitely would be something to investigate though.

Conrad

P.S. Superhuman is hiring iOS engineers — k now anyone? $1947 referral bonus. Learn more ( https://superhuman.com/jobs ). 

Sent via Superhuman ( https://sprh.mn/?vip=conrad@superhuman.com )

On Wed, Dec 06, 2017 at 1:01 PM, Fernando Seror Garcia < notifications@github.com > wrote:

Hi! We just hit this segmentation fault in our Rails app (a pretty large one BTW) and I wanted to let you know. Running any code that generates an exception on a Rails console triggers the segfault. Doing so on a normal irb session after loading pry-rescue does not.

While I do understand there might be a million of causes for this issues and I'm not providing enough context, I wanted to report this regardless. Please let me know what other information I can provide to help with the debugging.

The Ruby version is 2.3.4, the Rails version is 4.2.8 and it's confirmed to happen with pry-rescue 1.4.2 through 1.4.5. Removing pry-rescue eliminates the issue.

[1] pry(main)> [:a].map(&:name) /Users/user/Code/codebase/vendor/bundle/ruby/2.3.0/gems/interception-0.5/lib/cross_platform.rb:68: [BUG] Segmentation fault at 0x00000108cbd028 ruby 2.3.4p301 (2017-03-30 revision 58214) [x86_64-darwin14] -- 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:0030 p:---- s:0115 e:000114 CFUNC :binding c:0029 p:0015 s:0112 e:000109 BLOCK /Users/user/Code/codebase/vendor/bundle/ruby/2.3.0/gems/interception-0.5/lib/cross_platform.rb:68 [FINISH] c:0028 p:---- s:0107 e:000106 IFUNC :name c:0027 p:---- s:0105 e:000104 CFUNC :map c:0026 p:0010 s:0102 E:001270 EVAL (pry):1 [FINISH] c:0025 p:---- s:0100 e:000099 CFUNC :eval c:0024 p:0052 s:0094 E:0012e0 METHOD /Users/user/Code/codebase/vendor/bundle/ruby/2.3.0/gems/pry-0.11.3/lib/pry/pry_instance.rb:355 c:0023 p:0296 s:0089 E:001378 METHOD /Users/user/Code/codebase/vendor/bundle/ruby/2.3.0/gems/pry-0.11.3/lib/pry/pry_instance.rb:323 c:0022 p:0014 s:0079 E:001480 BLOCK /Users/user/Code/codebase/vendor/bundle/ruby/2.3.0/gems/pry-0.11.3/lib/pry/pry_instance.rb:243 [FINISH] c:0021 p:---- s:0077 e:000076 CFUNC :catch c:0020 p:0011 s:0073 E:001440 BLOCK /Users/user/Code/codebase/vendor/bundle/ruby/2.3.0/gems/pry-0.11.3/lib/pry/pry_instance.rb:242 [FINISH] c:0019 p:---- s:0071 e:000070 CFUNC :catch c:0018 p:0034 s:0067 E:001400 METHOD /Users/user/Code/codebase/vendor/bundle/ruby/2.3.0/gems/pry-0.11.3/lib/pry/pry_instance.rb:241 c:0017 p:0069 s:0060 E:000fc8 BLOCK /Users/user/Code/codebase/vendor/bundle/ruby/2.3.0/gems/pry-0.11.3/lib/pry/repl.rb:77 [FINISH] c:0016 p:---- s:0057 e:000056 CFUNC :loop c:0015 p:0009 s:0054 E:001070 METHOD /Users/user/Code/codebase/vendor/bundle/ruby/2.3.0/gems/pry-0.11.3/lib/pry/repl.rb:67 c:0014 p:0008 s:0051 E:001010 BLOCK /Users/user/Code/codebase/vendor/bundle/ruby/2.3.0/gems/pry-0.11.3/lib/pry/repl.rb:38 [FINISH] c:0013 p:0019 s:0049 E:001058 METHOD /Users/user/Code/codebase/vendor/bundle/ruby/2.3.0/gems/pry-0.11.3/lib/pry/input_lock.rb:61 c:0012 p:0033 s:0045 E:002090 METHOD /Users/user/Code/codebase/vendor/bundle/ruby/2.3.0/gems/pry-0.11.3/lib/pry/input_lock.rb:79 c:0011 p:0029 s:0040 E:002340 METHOD /Users/user/Code/codebase/vendor/bundle/ruby/2.3.0/gems/pry-0.11.3/lib/pry/repl.rb:38 c:0010 p:0023 s:0037 E:001a58 METHOD /Users/user/Code/codebase/vendor/bundle/ruby/2.3.0/gems/pry-0.11.3/lib/pry/repl.rb:13 c:0009 p:0240 s:0033 E:000058 METHOD /Users/user/Code/codebase/vendor/bundle/ruby/2.3.0/gems/pry-0.11.3/lib/pry/pry_class.rb:192 c:0008 p:0191 s:0027 E:001310 METHOD /Users/user/Code/codebase/vendor/bundle/ruby/2.3.0/gems/railties-4.2.8/lib/rails/commands/console.rb:110 c:0007 p:0015 s:0024 E:001598 METHOD /Users/user/Code/codebase/vendor/bundle/ruby/2.3.0/gems/railties-4.2.8/lib/rails/commands/console.rb:9 c:0006 p:0101 s:0020 E:000c48 METHOD /Users/user/Code/codebase/vendor/bundle/ruby/2.3.0/gems/railties-4.2.8/lib/rails/commands/commands_tasks.rb:68 c:0005 p:0036 s:0016 E:000c98 METHOD /Users/user/Code/codebase/vendor/bundle/ruby/2.3.0/gems/railties-4.2.8/lib/rails/commands/commands_tasks.rb:39 c:0004 p:0123 s:0012 E:000cf0 TOP /Users/user/Code/codebase/vendor/bundle/ruby/2.3.0/gems/railties-4.2.8/lib/rails/commands.rb:17 [FINISH] c:0003 p:---- s:0008 e:000007 CFUNC :require c:0002 p:0049 s:0004 E:000b30 EVAL bin/rails:6 [FINISH]

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub ( https://github.com/ConradIrwin/interception/issues/23 ) , or mute the thread ( https://github.com/notifications/unsubscribe-auth/AAFwQJNb2N4jEnZzTY_9T18stoCSyZJvks5s9wCQgaJpZM4Q4lLR ).

banister commented 6 years ago

Looks like a bug in Ruby itself, since the code is actually relying on Ruby's TracePoint API (for Ruby 2+) and not the C ext: https://github.com/ConradIrwin/interception/blob/master/lib/cross_platform.rb#L68

If possible, see if you can reproduce it on a later Ruby version, perhaps it's already been fixed.

ferdynton commented 6 years ago

I figured, but I still wanted to report it for posterity. Thanks for the work on both gems!

prikha commented 6 years ago

The bug is still present on 2.5.1 + Rails 5 + OS X Crushes ruby in the development the environment:

I use this snippet to reproduce the issue:

Model._save_callbacks.map(&:key)

The key is an instance variable which is not exposed, so it should throw NoMethodError but it just crashes.