Skip to content

Commit 65ebc6d

Browse files
committed
[GR-30237] NullPointerException during Ruby context pre-initialization.
PullRequest: truffleruby/2504
2 parents dc23d64 + a971447 commit 65ebc6d

File tree

3 files changed

+8
-6
lines changed

3 files changed

+8
-6
lines changed

mx.truffleruby/suite.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
{
88
"name": "regex",
99
"subdir": True,
10-
"version": "05b3f80c848cf272f3ff97897d734b1858867c8d",
10+
"version": "fa615de4e5396478d9eb303ee78048f31fe19f49",
1111
"urls": [
1212
{"url": "https://github.com/oracle/graal.git", "kind": "git"},
1313
{"url": "https://curio.ssw.jku.at/nexus/content/repositories/snapshots", "kind": "binary"},
@@ -16,7 +16,7 @@
1616
{
1717
"name": "sulong",
1818
"subdir": True,
19-
"version": "05b3f80c848cf272f3ff97897d734b1858867c8d",
19+
"version": "fa615de4e5396478d9eb303ee78048f31fe19f49",
2020
"urls": [
2121
{"url": "https://github.com/oracle/graal.git", "kind": "git"},
2222
{"url": "https://curio.ssw.jku.at/nexus/content/repositories/snapshots", "kind": "binary"},

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

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2013, 2020 Oracle and/or its affiliates. All rights reserved. This
2+
* Copyright (c) 2013, 2021 Oracle and/or its affiliates. All rights reserved. This
33
* code is released under a tri EPL/GPL/LGPL license. You can use it,
44
* redistribute it and/or modify it under the terms of the:
55
*
@@ -253,8 +253,6 @@ public void initialize() {
253253
if (isPreInitializing()) {
254254
// Cannot save the file descriptor in this SecureRandom in the image
255255
random = null;
256-
// Cannot save the root Java Thread instance in the image
257-
threadManager.resetMainThread();
258256
// Do not save image generator paths in the image heap
259257
hadHome = rubyHome != null;
260258
rubyHome = null;

src/main/java/org/truffleruby/RubyLanguage.java

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2015, 2020 Oracle and/or its affiliates. All rights reserved. This
2+
* Copyright (c) 2015, 2021 Oracle and/or its affiliates. All rights reserved. This
33
* code is released under a tri EPL/GPL/LGPL license. You can use it,
44
* redistribute it and/or modify it under the terms of the:
55
*
@@ -463,6 +463,10 @@ protected void initializeThread(RubyContext context, Thread thread) {
463463
@Override
464464
protected void disposeThread(RubyContext context, Thread thread) {
465465
if (thread == context.getThreadManager().getRootJavaThread()) {
466+
if (context.getEnv().isPreInitialization()) {
467+
// Cannot save the root Java Thread instance in the image
468+
context.getThreadManager().resetMainThread();
469+
}
466470
// Let the context shutdown cleanup the main thread
467471
return;
468472
}

0 commit comments

Comments
 (0)