Skip to content

Fixes for multibyte method names in backtrace - #9887

Draft
headius wants to merge 1 commit into
jruby:masterfrom
headius:properly_encode_method_names_for_trace
Draft

headius wants to merge 1 commit into
jruby:masterfrom
headius:properly_encode_method_names_for_trace

Conversation

@headius

@headius headius commented Oct 26, 2026

Copy link
Copy Markdown
Member

Multiple fixes here based around examples in #9879:

  • Don't register method ID as a symbol if it is not already in the symbol table.
  • Use decoded method ID when constructing MRI backtrace text.
  • Use decoded method ID when pushing backtrace in interpreter.
  • Use decoded method ID when defining JVM bytecode method.

This fixes the eval case in #9879 as well as simple cases of multibyte in a method name (which produced EncodingError during end-of-run backtrace printing before).

Multiple fixes here based around examples in jruby#9879:

* Don't register method ID as a symbol if it is not already in the
  symbol table.
* Use decoded method ID when constructing MRI backtrace text.
* Use decoded method ID when pushing backtrace in interpreter.
* Use decoded method ID when defining JVM bytecode method.

This fixes the eval case in jruby#9879 as well as simple
cases of multibyte in a method name (which produced EncodingError
during end-of-run backtrace printing before).
@headius headius added this to the JRuby 10.0.8.0 milestone Oct 26, 2026
@headius

headius commented Oct 26, 2026

Copy link
Copy Markdown
Member Author

High potential for this to impact encodings of method names elsewhere, such as in the backtrace_locations object. If unusual encodings are being used for method IDs, the resulting string in the Thread::Location object will potentially lose that encoding and represent the name as UTF-8. Round-tripping through JVM stack trace elements requires using properly-decoded java.lang.String which will make it impossible to recover the original identifier's encoding.

Draft until we see the impact and add tests for all cases.

@headius

headius commented Oct 27, 2026

Copy link
Copy Markdown
Member Author

This is going to be a bit trickier than hoped, since we have specific expectations about these "raw" identifiers even when they pass through Java code.

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.

Backtrace lines can have stale encoding flags for non-ASCII method names and instance_eval file names

1 participant