You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
See Issue #3729 for full info, but I don't think anything in the environment is notable, rather the test is what's notable.
Expected Behavior
Attempting to work around a thread safety bug in rspec-mocks, I wrote a spec which tries to count the number of times a callback was called.
it 'notifies the callback of each result' do
count = 0 # this is a Fixnum
mutex = Mutex.new
@thing.search('mime-type:message/rfc822') do
# synchronise on a common object so that we can be sure the count is updated atomically.
# I know I could have used the atomic gem, I'm just trying to get something to work right now.
mutex.synchronize { count += 1 } # a Fixnum + another Fixnum = a Fixnum
end
expect(count).to be(24)
end
This Thing#search method internally performs work in a thread pool, so the callback gets called from multiple threads, possibly all simultaneously. I think my code is thread-safe, so I expect this to pass, and about 4 out of 5 tries it does.
Actual Behavior
About 1 in 5 tries, I get this error:
Thing#search when a callback is provided notifies the callback of each result
Failure/Error: Unable to find matching line from backtrace
TypeError:
could not coerce Fixnum to interface java.util.Set
Now, it hasn't given me a stack trace this time, and I'm not even dealing with a set anywhere in my code, so I have no idea how this is even possible, but if it only happens sometimes, then I guess it's a thread safety bug in JRuby itself.
The text was updated successfully, but these errors were encountered:
you could try -d -w and hope to get some trace output, otherwise try to minimize a reproduction case extracted from your source. it seems too little (without taking a look in your source/app) to know whats going on. but it might be related to a thread-safety issue going on (hard to blame any code at this point).
Environment
See Issue #3729 for full info, but I don't think anything in the environment is notable, rather the test is what's notable.
Expected Behavior
Attempting to work around a thread safety bug in rspec-mocks, I wrote a spec which tries to count the number of times a callback was called.
This Thing#search method internally performs work in a thread pool, so the callback gets called from multiple threads, possibly all simultaneously. I think my code is thread-safe, so I expect this to pass, and about 4 out of 5 tries it does.
Actual Behavior
About 1 in 5 tries, I get this error:
Failure/Error: Unable to find matching line from backtrace
Now, it hasn't given me a stack trace this time, and I'm not even dealing with a set anywhere in my code, so I have no idea how this is even possible, but if it only happens sometimes, then I guess it's a thread safety bug in JRuby itself.
The text was updated successfully, but these errors were encountered: