Project

General

Profile

Actions

Backport #7123

closed

Segmentation fault in ruby 1.9.3-p194

Added by mscottford (M. Scott Ford) over 11 years ago. Updated almost 11 years ago.


Description

Example source for this issue is posted at https://github.com/mscottford/segfault-test, with reproduction instructions.

I'm encountering a segmentation fault in ruby 1.9.3-p194 on a project using Rails 3.2.8. The issue is only happening on Mac OS X. Members of my team that are running Linux do not have the same issue. The issue does not occur consistently; it sometimes takes several (20+) runs for the crash to happen.

test:

require 'spec_helper'

describe Widget do
  it "removes widget on rejection" do
    widget = Widget.create!

    expect do
      widget.reject!
    end.to change { described_class.count }.by(-1)

    GC.start
  end
end

model:

class Widget < ActiveRecord::Base
  attr_accessor :check_rejection_reason

  state_machine :initial => :requested do
    # I suspect that the issue is related to the issue being accessed in this closure after it has been deleted
    around_transition :requested => :none do |gm, transition, blk|
      gm.check_rejection_reason = true
      blk.call
      gm.check_rejection_reason = false
    end

    # This closure deletes the instance, but it is still being accessed by the `around_transition` above.
    after_transition any => :none do |gm, transition|
      gm.destroy
    end

    on :reject do
      transition :requested => :none
    end
  end
end

Files

ruby_2012-10-08-204054_cloudraker.crash (39.1 KB) ruby_2012-10-08-204054_cloudraker.crash mscottford (M. Scott Ford), 10/09/2012 10:16 AM
error_log.txt (211 KB) error_log.txt Rails output error log rsluiters (Ralph Sluiters), 10/17/2012 07:21 PM
Bug 7123 - seangeo.crash (64.7 KB) Bug 7123 - seangeo.crash seangeo (Sean Geoghegan), 10/25/2012 11:31 AM
backport_r37088_r37083_r37082_r37076_r37075_to_193.patch (21.7 KB) backport_r37088_r37083_r37082_r37076_r37075_to_193.patch authorNari (Narihiro Nakamura), 11/13/2012 06:13 PM
Actions

Also available in: Atom PDF

Like0
Like0Like0Like0Like0Like0Like0Like0Like0Like0Like0Like0Like0Like0Like0