Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

"could not coerce Fixnum to interface java.util.Set" from code that isn't dealing with sets #3730

Closed
hakanai opened this issue Mar 14, 2016 · 2 comments

Comments

@hakanai
Copy link

hakanai commented Mar 14, 2016

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.

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:

  1. 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.

@kares
Copy link
Member

kares commented Mar 14, 2016

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).

@kares kares added this to the Invalid or Duplicate milestone Jun 23, 2017
@kares
Copy link
Member

kares commented Jun 23, 2017

no response in a year+ thus closing

@kares kares closed this as completed Jun 23, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants