Skip to content

Instantly share code, notes, and snippets.

@eric
Created February 1, 2012 21:14
Show Gist options
  • Save eric/1719510 to your computer and use it in GitHub Desktop.
Save eric/1719510 to your computer and use it in GitHub Desktop.
#!/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

OS X

$ ruby break-ruby-atomic.rb 
break-ruby-atomic.rb:12: [BUG] Segmentation fault
ruby 1.8.7 (2010-01-10 patchlevel 249) [universal-darwin11.0]

Abort

Linux

$ ruby break-ruby-atomic.rb 
break-ruby-atomic.rb:12: [BUG] Segmentation fault
ruby 1.8.7 (2011-02-18 patchlevel 334) [x86_64-linux], MBARI 0x6770, Ruby Enterprise Edition 2011.03
@eric
Copy link
Author

eric commented Feb 2, 2012

GitHub Issue: headius/ruby-atomic#11

@eric
Copy link
Author

eric commented Feb 2, 2012

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment