Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Airbrake gem segfaults on Circle CI #204

Closed
joshuasiler opened this issue May 1, 2017 · 5 comments
Closed

Airbrake gem segfaults on Circle CI #204

joshuasiler opened this issue May 1, 2017 · 5 comments
Labels

Comments

@joshuasiler
Copy link

Any idea what would cause this?

/home/ubuntu/HiringThing/vendor/bundle/ruby/2.1.0/gems/airbrake-ruby-2.2.0/lib/airbrake-ruby/filters/thread_filter.rb:38: [BUG] Segmentation fault at 0x00000000000000
ruby 2.1.2p95 (2014-05-08 revision 45877) [x86_64-linux]

-- Control frame information -----------------------------------------------
c:0065 p:---- s:0304 e:000303 CFUNC  :inspect
c:0064 p:---- s:0302 e:000301 CFUNC  :inspect
c:0063 p:0019 s:0299 e:000295 BLOCK  /home/ubuntu/HiringThing/vendor/bundle/ruby/2.1.0/gems/airbrake-ruby-2.2.0/lib/airbrake-ruby/filters/thread_filter.rb:38 [FINISH]
c:0062 p:---- s:0292 e:000291 IFUNC 
c:0061 p:---- s:0290 e:000289 CFUNC  :map
c:0060 p:---- s:0288 e:000287 CFUNC  :with_object
c:0059 p:0016 s:0284 e:000283 METHOD /home/ubuntu/HiringThing/vendor/bundle/ruby/2.1.0/gems/airbrake-ruby-2.2.0/lib/airbrake-ruby/filters/thread_filter.rb:38
c:0058 p:0067 s:0280 e:000279 METHOD /home/ubuntu/HiringThing/vendor/bundle/ruby/2.1.0/gems/airbrake-ruby-2.2.0/lib/airbrake-ruby/filters/thread_filter.rb:15
c:0057 p:0026 s:0272 e:000271 BLOCK  /home/ubuntu/HiringThing/vendor/bundle/ruby/2.1.0/gems/airbrake-ruby-2.2.0/lib/airbrake-ruby/filter_chain.rb:64 [FINISH]
c:0056 p:---- s:0269 e:000268 CFUNC  :each
c:0055 p:0018 s:0266 e:000265 METHOD /home/ubuntu/HiringThing/vendor/bundle/ruby/2.1.0/gems/airbrake-ruby-2.2.0/lib/airbrake-ruby/filter_chain.rb:62
c:0054 p:0079 s:0262 e:000261 METHOD /home/ubuntu/HiringThing/vendor/bundle/ruby/2.1.0/gems/airbrake-ruby-2.2.0/lib/airbrake-ruby/notifier.rb:121
c:0053 p:0022 s:0254 e:000253 METHOD /home/ubuntu/HiringThing/vendor/bundle/ruby/2.1.0/gems/airbrake-ruby-2.2.0/lib/airbrake-ruby/notifier.rb:51
c:0052 p:0057 s:0248 e:000247 METHOD /home/ubuntu/HiringThing/vendor/bundle/ruby/2.1.0/gems/airbrake-6.0.0/lib/airbrake/rails/action_controller.rb:17
c:0051 p:0063 s:0241 e:000240 METHOD /home/ubuntu/HiringThing/app/controllers/client_api_controller.rb:10
@kyrylo kyrylo added the Bug label May 2, 2017
@kyrylo
Copy link
Contributor

kyrylo commented May 2, 2017

Thanks for reporting this!

Some other user complained about this bug, too. They were also using Ruby 2.1 (2.1.2p95). So far it seems like this problem is isolated to that version of Ruby (a wild guess).

Could you downgrade airbrake (or simply not load it) and show what the following prints:

Thread.current.keys.map.with_object({}) { |key, h| h[key] = Thread.current[key].inspect }

Maybe there's some weird IO object there that can't be "inspected".

Do you know what test generates this error?

@ilchanka
Copy link

ilchanka commented May 2, 2017

I was able to reproduce this with ruby 2.1.2
calling

th[:__recursive_key__]

will blow this

@ilchanka
Copy link

ilchanka commented May 2, 2017

Looks like a bug in ruby https://bugs.ruby-lang.org/issues/10579

the way to reproduce

ruby -e '{["foo"]=>nil}; p Thread.current[:__recursive_key__]'

@joshuasiler
Copy link
Author

joshuasiler commented May 2, 2017

Not sure why but it doesn't crash when running on my dev local (also 2.1.2p95), only on circle (edit: mystery solved, actually I was using 2.0.0 version of the gem locally)

@kyrylo
Copy link
Contributor

kyrylo commented May 2, 2017

Thanks @ilchanka, this is a very useful link.

@joshuasiler I managed to reproduce it locally, so luckily it's easier to think of a fix. However, if nothing works, then we can avoid loading ThreadFilter on a small subset of Rubies.

kyrylo added a commit that referenced this issue May 4, 2017
Fixes #204 (Airbrake gem segfaults on Circle CI)

The main reason to use `inspect` here was to avoid a bug with IO objects
in Rails apps.

I stumbled upon an edge case while running the thread filter against a
Rails app. The app would stuck because `io_obj.to_json` would never
return. The `io_obj` was open. Closed IO objects raise IOError, which
we already handle.

Given that we stop using `inspect`, I think this also fixes #204.
kyrylo added a commit that referenced this issue May 4, 2017
Fixes #204 (Airbrake gem segfaults on Circle CI)

The main reason to use `inspect` here was to avoid a bug with IO objects
in Rails apps.

I stumbled upon an edge case while running the thread filter against a
Rails app. The app would stuck because `io_obj.to_json` would never
return. The `io_obj` was open. Closed IO objects raise IOError, which
we already handle.

Given that we stop using `inspect`, I think this also fixes #204.
kyrylo added a commit that referenced this issue May 4, 2017
Fixes #204 (Airbrake gem segfaults on Circle CI)

The main reason to use `inspect` here was to avoid a bug with IO objects
in Rails apps.

I stumbled upon an edge case while running the thread filter against a
Rails app. The app would stuck because `io_obj.to_json` would never
return. The `io_obj` was open. Closed IO objects raise IOError, which
we already handle.

Given that we stop using `inspect`, I think this also fixes #204.
kyrylo added a commit that referenced this issue May 4, 2017
Fixes #204 (Airbrake gem segfaults on Circle CI)

I stumbled upon an edge case while running the thread filter against a
Rails app. The app would stuck because `io_obj.to_json` would never
return. The `io_obj` was open. Closed IO objects raise IOError, which
we already handle.

To make sure we avoid any kind of segfaults, we ignore
`:__recursive_key__`, which holds data for PrettyPrint.
kyrylo added a commit that referenced this issue May 4, 2017
Fixes #204 (Airbrake gem segfaults on Circle CI)

I stumbled upon an edge case while running the thread filter against a
Rails app. The app would stuck because `io_obj.to_json` would never
return. The `io_obj` was open. Closed IO objects raise IOError, which
we already handle.

To make sure we avoid any kind of segfaults, we ignore
`:__recursive_key__`, which holds data for PrettyPrint.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants