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

[Truffle] Intermittent Array error when running activemodel tests #3822

Closed
bjfish opened this issue Apr 21, 2016 · 7 comments
Closed

[Truffle] Intermittent Array error when running activemodel tests #3822

bjfish opened this issue Apr 21, 2016 · 7 comments
Assignees
Milestone

Comments

@bjfish
Copy link
Contributor

bjfish commented Apr 21, 2016

Environment

Expected Behavior

The tests complete.

Actual Behavior

From the activemodel directory run:
jruby+truffle run --require-pattern 'test/**/**/railtie_test.rb' -r exclude_tests -- -I test -e 'nil'
Results in the following error occasionally:

Run options: --seed 22666

# Running:

ES

Finished in 2.837000s, 0.7050 runs/s, 0.0000 assertions/s.

  1) Error:
RailtieTest#test_secure_password_min_cost_is_true_in_the_test_environment:
RubyTruffleError: internal implementation error - ArrayIndexOutOfBoundsException 103 org.jruby.truffle.core.array.ObjectArrayMirror.get(ObjectArrayMirror.java:27)
    /Users/brandonfish/Documents/rails/railties/lib/rails/application.rb:321:in `include?'
    /Users/brandonfish/Documents/rails/railties/lib/rails/application.rb:321:in `add_lib_to_load_path!'
    /Users/brandonfish/Documents/rails/railties/lib/rails/application.rb:92:in `inherited'
    /Users/brandonfish/Documents/rails/activemodel/test/cases/railtie_test.rb:13:in `initialize'
    /Users/brandonfish/Documents/rails/activemodel/test/cases/railtie_test.rb:13:in `new'
    /Users/brandonfish/Documents/rails/activemodel/test/cases/railtie_test.rb:13:in `setup'
    /Users/brandonfish/Documents/rails/activemodel/.jruby+truffle_bundle/mocks/shims.rb:17:in `block (3 levels) in run'

2 runs, 0 assertions, 0 failures, 1 errors, 1 skips
@bjfish bjfish added the truffle label Apr 21, 2016
@eregon eregon self-assigned this Apr 22, 2016
@eregon eregon added this to the truffle-dev milestone Apr 22, 2016
@eregon
Copy link
Member

eregon commented Apr 22, 2016

Thanks for the report!
Running this with assertions enabled triggers an assert in Hash storage verification, investigating.

@eregon
Copy link
Member

eregon commented Apr 22, 2016

It looks like this uses minitest/parallel, which ends up spawning 2 threads by default.
This in turns seems to corrupt some Hash and likely some Array too.
I am not sure whether these races are supposed to happen or if there is some bug in our autoload or in the code assuming Array and Hash to be thread-safe.

@eregon eregon assigned pitr-ch and unassigned eregon Apr 22, 2016
@eregon
Copy link
Member

eregon commented Apr 22, 2016

Assigning to @pitr-ch since we will run tests in single-thread mode for now to make them more deterministic. I think we can close this issue once that is done, as the error should not appear anymore.

@thedarkone
Copy link
Contributor

Just a quick note, Rails expects its boot process to be run single-threadedly, don't know what is happening here...

$LOAD_PATH obj must be made thread safe.

@pitr-ch
Copy link
Member

pitr-ch commented Apr 24, 2016

fixed in 49e97eb

@thedarkone yeah but this is not a rails boot process but lazy loading parts of a ActiveModel treating it treated as a library by parallel minitest. We are disabling this for now, because we are not thread-safe enough at the moment, which is know issue we work on.

Yes, it does. $LOADED_FEATURES as well.

@pitr-ch pitr-ch closed this as completed Apr 24, 2016
@thedarkone
Copy link
Contributor

this is not a rails boot process but lazy loading parts of a ActiveModel treating it
as a library by parallel minitest. We are disabling this for now, because we are not thread-safe enough at the moment, which is know issue we work on.

Making sure we're on the same page: even with all the outstanding jruby-truffle thread-safety issues fixed, you still wouldn't be allowed to parallel load any part of Rails (including ActiveModel).

@pitr-ch
Copy link
Member

pitr-ch commented Apr 24, 2016

After autoload is fixed then it should be ok, assuming that other ruby code is not also touching $LOADED_FEATURES and $LOAD_PATH (which is probably happening in the tests), since those are for now protected only from the internal side. Other things may broke though since Ruby code tends to rely on MRI's GIL.

@enebo enebo added this to the Non-Release milestone Dec 7, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants