diff --git a/CHANGELOG.md b/CHANGELOG.md index 7b69be0a..3bbdbacc 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -3,6 +3,9 @@ Airbrake Ruby Changelog ### master +* Fixed segfault in `ThreadFilter` on Ruby 2.1.3 + ([#228](https://github.com/airbrake/airbrake-ruby/pull/228)) + ### [v2.2.5][v2.2.5] (May 23, 2017) * Fixed bug when the block form of `notify` would run its block for ignored diff --git a/lib/airbrake-ruby/filters/thread_filter.rb b/lib/airbrake-ruby/filters/thread_filter.rb index e057a137..03105b7a 100644 --- a/lib/airbrake-ruby/filters/thread_filter.rb +++ b/lib/airbrake-ruby/filters/thread_filter.rb @@ -21,6 +21,13 @@ class ThreadFilter Numeric ].freeze + ## + # @return [Array] the list of ignored fiber variables + IGNORED_FIBER_VARIABLES = [ + # https://github.com/airbrake/airbrake-ruby/issues/229 + :__recursive_key__ + ].freeze + def initialize @weight = 110 end @@ -57,6 +64,7 @@ def thread_variables(th) def fiber_variables(th) th.keys.map.with_object({}) do |key, h| + next if IGNORED_FIBER_VARIABLES.any? { |v| v == key } h[key] = sanitize_value(th[key]) end end diff --git a/spec/filters/thread_filter_spec.rb b/spec/filters/thread_filter_spec.rb index 5e7cf5fe..6c2b529d 100644 --- a/spec/filters/thread_filter_spec.rb +++ b/spec/filters/thread_filter_spec.rb @@ -119,6 +119,18 @@ def new_thread ) end end + + it "ignores the :__recursive_key__ fiber variable" do + key = :__recursive_key__ + + new_thread do |th| + th[key] = key + subject.call(notice) + end + + fiber_variables = notice[:params][:thread][:fiber_variables] + expect(fiber_variables[key]).to be_nil + end end describe "fiber variables" do