Skip to content

Commit ebf798a

Browse files
committed
[GR-18163] Fix NoClassDefFoundError instead of StackOverflowError on JVM.
PullRequest: truffleruby/1993
2 parents 15763c3 + ebba39a commit ebf798a

File tree

2 files changed

+6
-0
lines changed

2 files changed

+6
-0
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ Bug fixes:
1515
* Fixed issue with `spawn` when `:close` redirect is used (#2097).
1616
* Fixed `coverage` issue when `*eval` is used (#2078).
1717
* Use expanded load paths for feature matching (#1501).
18+
* Fixed `SystemStackError` sometimes replaced by an internal Java `NoClassDefFoundError` on JVM (#1743).
1819

1920
Compatibility:
2021

src/main/java/org/truffleruby/RubyContext.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,7 @@
5555
import org.truffleruby.core.thread.ThreadManager;
5656
import org.truffleruby.core.time.GetTimeZoneNode;
5757
import org.truffleruby.debug.MetricsProfiler;
58+
import org.truffleruby.extra.ffi.Pointer;
5859
import org.truffleruby.interop.InteropManager;
5960
import org.truffleruby.language.CallStackManager;
6061
import org.truffleruby.language.LexicalScope;
@@ -213,6 +214,10 @@ public RubyContext(RubyLanguage language, TruffleLanguage.Env env) {
213214
coverageManager = new CoverageManager(this, instrumenter);
214215
Metrics.printTime("after-instruments");
215216

217+
// Initialize RaiseException eagerly so StackOverflowError is correctly handled and does not become
218+
// NoClassDefFoundError: Could not initialize class org.truffleruby.language.control.RaiseException
219+
Pointer.UNSAFE.ensureClassInitialized(RaiseException.class);
220+
216221
Metrics.printTime("after-context-constructor");
217222
}
218223

0 commit comments

Comments
 (0)