Skip to content

Commit

Permalink
Ensure all frame names are non-null
Browse files Browse the repository at this point in the history
These names will leak out in stack traces so may need to be
reconsidered.
  • Loading branch information
headius committed Apr 5, 2024
1 parent 823dce1 commit 18e8a0f
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 4 deletions.
6 changes: 3 additions & 3 deletions core/src/main/java/org/jruby/ir/interpreter/Interpreter.java
Original file line number Diff line number Diff line change
Expand Up @@ -127,15 +127,15 @@ public static IRubyObject INTERPRET_BLOCK(ThreadContext context, Block block, IR
}

public static IRubyObject INTERPRET_CLASS(ThreadContext context, IRScope body, RubyModule clazz) {
return interpretFrameScope(context, null, body, clazz, null, Visibility.PUBLIC, clazz, null, null, Block.NULL_BLOCK);
return interpretFrameScope(context, null, body, clazz, null, Visibility.PUBLIC, clazz, "<class>", null, Block.NULL_BLOCK);
}

public static IRubyObject INTERPRET_MODULE(ThreadContext context, IRScope body, RubyModule clazz) {
return interpretFrameScope(context, null, body, clazz, null, Visibility.PUBLIC, clazz, null, null, Block.NULL_BLOCK);
return interpretFrameScope(context, null, body, clazz, null, Visibility.PUBLIC, clazz, "<module>", null, Block.NULL_BLOCK);
}

public static IRubyObject INTERPRET_METACLASS(ThreadContext context, IRScope body, RubyModule clazz, Visibility visibility) {
return interpretFrameScope(context, null, body, clazz, context.getCurrentScope(), visibility, clazz, null, null, Block.NULL_BLOCK);
return interpretFrameScope(context, null, body, clazz, context.getCurrentScope(), visibility, clazz, "<metaclass>", null, Block.NULL_BLOCK);
}

public static IRubyObject INTERPRET_METHOD(ThreadContext context, IRScope body, RubyModule implClass,
Expand Down
9 changes: 8 additions & 1 deletion core/src/main/java/org/jruby/runtime/Frame.java
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,7 @@ public final class Frame {
* when needed.
*/
public Frame() {
name = "<root>";
}

/**
Expand All @@ -112,6 +113,7 @@ private Frame(Block nullBlock) {
*/
private Frame(Frame frame) {
assert frame.block != null;
assert frame.name != null;

this.self = frame.self;
this.name = frame.name;
Expand All @@ -135,6 +137,7 @@ public void updateFrame() {
* @param name The name of the method being called
*/
public void updateFrame(String name) {
assert name != null;
this.name = name;
}

Expand All @@ -147,6 +150,7 @@ public void updateFrame(String name) {
public void updateFrame(Frame frame) {
Block block = frame.block;
assert block != null;
assert frame.name != null;

this.self = frame.self;
this.name = frame.name;
Expand All @@ -165,6 +169,7 @@ public void updateFrame(Frame frame) {
*/
public void updateFrame(RubyModule klazz, IRubyObject self, String name, Block block) {
assert block != null;
assert name != null;
this.self = self;
this.name = name;
this.klazz = klazz;
Expand All @@ -182,6 +187,7 @@ public void updateFrame(RubyModule klazz, IRubyObject self, String name, Block b
*/
public void updateFrame(RubyModule klazz, IRubyObject self, String name, Visibility visibility, Block block) {
assert block != null;
assert name != null;
this.self = self;
this.name = name;
this.klazz = klazz;
Expand All @@ -196,7 +202,7 @@ public void updateFrame(RubyModule klazz, IRubyObject self, String name, Visibil
*/
public void updateFrameForEval(IRubyObject self) {
this.self = self;
this.name = null;
this.name = "<eval>";
this.visibility = Visibility.PRIVATE;
}

Expand Down Expand Up @@ -267,6 +273,7 @@ public void setKlazz(RubyModule klazz) {
* @param name the new name
*/
public void setName(String name) {
assert name != null;
this.name = name;
}

Expand Down

0 comments on commit 18e8a0f

Please sign in to comment.