Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Multibyte identifiers not marshaled correctly #3688

headius opened this Issue Feb 19, 2016 · 3 comments


None yet
1 participant
Copy link

headius commented Feb 19, 2016


JRuby (and likely

Expected Behavior

When a class or instance variable has multibyte characters, it needs to marshal that name as though it were an encoded symbol. Basically, where we currently dump a "plain" bytes version of the identifer, we need to dump it with the "encoding instance variable" logic used for proper symbols. This way we can reconstitute the original name and match it up properly on the load side.

Actual Behavior

In actuality, we are stripping the multibyte nature of those names, and they come out mangled on the other side.

Given this script (based on MRI TestMarshal#test_unloadable_userdef:

class Foo
  def bar
    c = eval "
      class X\u{23F0 23F3} < Time
        class << self
          undef _load
    o =
    p Marshal.load(Marshal.dump(o))

We currently get the following marshaled output (note the mangled name of the class):


I attempted to fix this by actually creating symbols for these elements, but there's something missing on the loading side. Here's my patch:

The marshaled output looks better:


But I still get an error from the full script above:

ArgumentError: undefined class/module Foo::X��
   load at org/jruby/
    bar at -e:1
  <top> at -e:1

We are not reconstituting the string properly, it seems.

Since this is not a regression or new behavior, I'm going to exclude the related CRuby 2.3 tests for now.


This comment has been minimized.

Copy link
Member Author

headius commented Apr 27, 2017

Circling back to this because we're fixing up symbol encoding stuff.

If I run this as-is today on (master) I get this:

$ jruby blah.rb
ArgumentError: undefined class/module Foo::X??
    load at org/jruby/
     bar at blah.rb:11
  <main> at blah.rb:14

The multibyte chars are at least rendering as question marks now, but the error remains.

If I run this without the eval (and use ) as the name of the class, the error changes to a marshaling error:

$ jruby blah.rb
TypeError: class Foo::Xø needs to have method `_load'
         load at org/jruby/
  <class:Foo> at blah.rb:11
       <main> at blah.rb:1

...which matches MRI. So it seems that the problem relates to the eval of the multibyte characters.

@headius headius added the encoding label Apr 27, 2017


This comment has been minimized.

Copy link
Member Author

headius commented Apr 27, 2017

I suspect this will be fixed by getting the rest of identifiers to use proper bytelists, which @enebo is working on now.


This comment has been minimized.

Copy link
Member Author

headius commented May 16, 2018

This does not appear to be fixed in 9.2, but it may simply be a lack of symbol/identifier logic fixes for Marshal. @enebo maybe you can take a look at this?

Meanwhile I'm retargeting for 9.2.1.

@headius headius modified the milestones: JRuby, JRuby May 16, 2018

@enebo enebo closed this in f176877 Jun 14, 2018

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.