headius/ruby-atomic — Issue #11: Segfault in MRI 1.8
Author: eric
Created: 2012-02-01 21:22:34+00:00
State: open

Here is a repro for causing MRI 1.8 to segfault: https://gist.github.com/1719510

I've seen it happen on OS X and Linux.

To make sure it doesn't get lost, here is the code:

``` ruby
#!/usr/bin/env ruby

require 'atomic'

atomic1 = Atomic.new([ -1, 0 ])
atomic2 = Atomic.new(0)

array = []

1000.times do |idx|
atomic1.update do |old_values|
array << old_values.inspect

new_values = Array.new(2)
new_values[0] = old_values[0] + rand
new_values[1] = old_values[1] + rand

new_values
end

atomic2.update { |v| v + 1 }

if idx % 100 == 0
GC.start
end
end
```