Skip to content

[ji] allow Java errors from Ruby threads to reach the handler#6679

Merged
headius merged 11 commits intojruby:masterfrom
kares:bubble-thread-error
Oct 12, 2021
Merged

[ji] allow Java errors from Ruby threads to reach the handler#6679
headius merged 11 commits intojruby:masterfrom
kares:bubble-thread-error

Conversation

@kares
Copy link
Member

@kares kares commented May 20, 2021

java.lang.Error instances will no longer be considered exiting exceptions for Ruby threads,
the Ruby thread instance will instead bubble these out and let the Java level uncaught handler take care of these.

this changes JRuby user-behavior in cases such as: Thread.start { raise java.lang.Error.new('bleh') } but the risk of breakage is legit opposed to potentially "handling" errors such as java.lang.OutOfMemoryError at the Ruby level.

besides, there's also some new Java API being exposed on the RubyThread as well as naming unification for abortOnException naming on the Ruby runtime + MRI handles report_on_exception as a true/false flag - no special handling for nil necessary. HINT: JRuby did return the incorrect object on Thread#report_on_exception and friends.

@kares kares force-pushed the bubble-thread-error branch from 5879b7a to ea82acf Compare May 24, 2021 09:40
@kares kares force-pushed the bubble-thread-error branch from ea82acf to b8a240a Compare May 24, 2021 09:51
@kares kares marked this pull request as ready for review May 24, 2021 09:51
@kares kares added this to the JRuby 9.3.0.0 milestone May 24, 2021
@kares
Copy link
Member Author

kares commented May 25, 2021

one potential concern for improvement, even though java.lang.Error reaches the uncaught Java handler, do we still want to keep the existing error around? (Thread#status will not report correctly in case the Error is actually considered handled)

@headius
Copy link
Member

headius commented May 25, 2021

Good point! I think we would want to still report that as the terminal exception for the thread.

kares added 4 commits May 26, 2021 14:05
* master: (165 commits)
  Also remove pending_interrupt? tags
  Thread.current.raise should also set interrupt
  Cleanup TestThread excludes
  Thread.current.raise should honor interrupt mask
  Add uninterruptible logic for Kernel#p
  Rework Queue#pop to restore retry loop
  Separate blocking from nonblocking tasks
  RUBY not RB
  Should use blocking thread poll before IO op
  This should be &&
  Add tags for new failing specs
  Update to ruby/spec@b65d01f
  Update to ruby/mspec@9542a88
  Do not loop at this level, caller should loop
  Document what this lines up with in CRuby
  Add blocking thread poll
  Update handle_interrupt tags
  Address review comment
  Split up Windows and Solaris FFI file logic
  Avoid checking FFI constants for usability
  ...
@headius headius modified the milestones: JRuby 9.3.0.0, JRuby 9.3.1.0 Aug 19, 2021
* master: (63 commits)
  Bump metaspace up 50% to see if we are leaking
  Update test_ftp to get stdlib tests green
  Update version numbers to match CRuby 2.6.8
  Update stdlib files not sourced from gems
  Updated jossl is a bit larger
  Switch to released ffi 1.15.4
  Update rexml to 3.1.9.1 to match ruby 2.6.8
  ffi 1.15.4
  Update owned dependencies backport9 and options
  Missed an updated pom.xml for jffi
  Update did_you_mean to 1.3.0 to match ruby 2.6.8
  Update to jruby-openssl 0.10.7
  Update JNR dependencies
  restore api compatibility with nio4r
  Create and use pure-bash dirname and basename
  update surefire plugin
  tags off TestBigDecimal#test_new and TestBigMath#test_sqrt because these already pass.
  fix failing TestBigDecimal#test_ctov
  fix failing TestBigDecimal#test_to_special_string
  fix failing TestBigDecimal#test_power_of_negative_infinity, #test_power_of_positive_infinity and #test_power_of_zero
  ...
@kares
Copy link
Member Author

kares commented Sep 6, 2021

hmm, seems like bubbling up Java errors is revealing a bug with test/unit's parallel test runner:

java.lang.NullPointerException
	at org.jruby.util.io.PosixShim.read(PosixShim.java:158)
	at org.jruby.util.io.OpenFile$2.run(OpenFile.java:1325)
	at org.jruby.util.io.OpenFile$2.run(OpenFile.java:1316)
	at org.jruby.RubyThread.executeReadWrite(RubyThread.java:1747)
	at org.jruby.util.io.OpenFile.readInternal(OpenFile.java:1384)
	at org.jruby.RubyIO.getPartial(RubyIO.java:3093)
	at org.jruby.RubyIO.readpartial(RubyIO.java:3025)

not sure I guess we would need an uncaught Java handler during the MRI suite why this suddenly matters ...

@ahorek
Copy link
Contributor

ahorek commented Sep 7, 2021

hmm, seems like bubbling up Java errors is revealing a bug with test/unit's parallel test runner:

java.lang.NullPointerException
	at org.jruby.util.io.PosixShim.read(PosixShim.java:158)
	at org.jruby.util.io.OpenFile$2.run(OpenFile.java:1325)
	at org.jruby.util.io.OpenFile$2.run(OpenFile.java:1316)
	at org.jruby.RubyThread.executeReadWrite(RubyThread.java:1747)
	at org.jruby.util.io.OpenFile.readInternal(OpenFile.java:1384)
	at org.jruby.RubyIO.getPartial(RubyIO.java:3093)
	at org.jruby.RubyIO.readpartial(RubyIO.java:3025)

not sure I guess we would need an uncaught Java handler during the MRI suite why this suddenly matters ...

test workers were dying because any ThreadKill exception killed the whole process. With my changes, all tests passed, @kares could you review the logic again?

@headius
Copy link
Member

headius commented Oct 11, 2021

I'm going to untarget this until it looks like we have a release target in mind.

@headius headius removed this from the JRuby 9.3.1.0 milestone Oct 11, 2021
@kares kares force-pushed the bubble-thread-error branch from 000413d to b4d61c6 Compare October 12, 2021 06:07
@headius headius merged commit ef98424 into jruby:master Oct 12, 2021
@headius headius added this to the JRuby 9.3.1.0 milestone Oct 12, 2021
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

Successfully merging this pull request may close these issues.

3 participants