Skip to content

Commit ebba39a

Browse files
committed
Fix NoClassDefFoundError instead of StackOverflowError on JVM
* Fixes #1743.
1 parent 05fe851 commit ebba39a

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
@@ -13,6 +13,7 @@ Bug fixes:
1313
* Fixed issue with `Kernel#freeze` not freezing singleton class (#2093).
1414
* Fixed `String#encode` with options issue (#2091, #2095, @LillianZ)
1515
* Fixed issue with `spawn` when `:close` redirect is used (#2097).
16+
* Fixed `SystemStackError` sometimes replaced by an internal Java `NoClassDefFoundError` on JVM (#1743).
1617

1718
Compatibility:
1819

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

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,7 @@
5454
import org.truffleruby.core.thread.ThreadManager;
5555
import org.truffleruby.core.time.GetTimeZoneNode;
5656
import org.truffleruby.debug.MetricsProfiler;
57+
import org.truffleruby.extra.ffi.Pointer;
5758
import org.truffleruby.interop.InteropManager;
5859
import org.truffleruby.language.CallStackManager;
5960
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)