Created
April 4, 2012 02:38
-
-
Save andrewytliu/2297345 to your computer and use it in GitHub Desktop.
Mutex with fiber: segfault under 1.9.2
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
m = Mutex.new | |
i = [0] | |
a = Fiber.new do | |
t = nil | |
m.synchronize { t = i[0] } | |
Fiber.yield | |
m.synchronize { i[0] = t + 1 } | |
end | |
b = Fiber.new do | |
t = nil | |
m.synchronize { t = i[0] } | |
Fiber.yield | |
m.synchronize { i[0] = t + 1 } | |
end | |
p i # => [0] | |
a.resume | |
b.resume | |
a.resume # 1 | |
b.resume # 1 | |
p i # => [1] # should be [2] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment