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

Unmarshaled hash with non-ascii keys is corrupted #1624

Closed
deepj opened this issue Mar 17, 2019 · 4 comments
Closed

Unmarshaled hash with non-ascii keys is corrupted #1624

deepj opened this issue Mar 17, 2019 · 4 comments
Assignees
Labels
Milestone

Comments

@deepj
Copy link

deepj commented Mar 17, 2019

This issue is similar to jruby/jruby#5523 reported by @larskanis. But it behaves a bit differently in TruffleRuby. There was the same issue with arrays already fixed in TruffleRuby #1530

The used code is from @larskanis

TruffleRuby 1.0.0-RC13

irb(main):001:0> h={:€a=>nil, :€c=>nil, :€h=>nil}
=> {:€a=>nil, :€c=>nil, :€h=>nil}
irb(main):002:0> Marshal.load(Marshal.dump(h))
=> {:"€a"=>nil, :"\xE2\x82\xACc"=>nil, :"\xE2\x82\xACh"=>nil}
irb(main):003:0> Marshal.load(Marshal.dump(h)) == h
=> false

Ruby 2.5.3

irb(main):001:0> h={:€a=>nil, :€c=>nil, :€h=>nil}
=> {:€a=>nil, :€c=>nil, :€h=>nil}
irb(main):002:0> Marshal.load(Marshal.dump(h))
=> {:€a=>nil, :€c=>nil, :€h=>nil}
irb(main):003:0> Marshal.load(Marshal.dump(h)) == h
=> true
@nirvdrum nirvdrum self-assigned this May 28, 2019
@nirvdrum nirvdrum added the bug label May 28, 2019
@deepj deepj closed this as completed Jun 8, 2020
@eregon eregon reopened this Jun 19, 2020
@dentarg
Copy link

dentarg commented Jul 5, 2021

Seems to happen when using truffleruby-head-ubuntu-18.04 with Addressable (build ran 2 days ago): https://github.com/sporkmonger/addressable/runs/2977469877?check_suite_focus=true#step:7:87

The Marshal dump is from 2012: sporkmonger/addressable@1eb715d

truffleruby-21.1.0-ubuntu-18.04 works fine though: https://github.com/sporkmonger/addressable/runs/2988483622?check_suite_focus=true#step:5:13

@eregon
Copy link
Member

eregon commented Jul 5, 2021

Thanks for the report! We'll look into that.

@eregon eregon self-assigned this Jul 5, 2021
@eregon
Copy link
Member

eregon commented Jul 5, 2021

The problem in the original example is that some of the Symbols get a BINARY encoding when reloaded:

v = {:€a=>nil, :€c=>nil, :€h=>nil}
p v
r = Marshal.load(Marshal.dump(v))
p r
p r == v

p v.keys.map(&:encoding)
p r.keys.map(&:encoding)
{:"€a"=>nil, :"€c"=>nil, :"€h"=>nil}
{:"€a"=>nil, :"\xE2\x82\xACc"=>nil, :"\xE2\x82\xACh"=>nil}
false
[#<Encoding:UTF-8>, #<Encoding:UTF-8>, #<Encoding:UTF-8>]
[#<Encoding:UTF-8>, #<Encoding:ASCII-8BIT>, #<Encoding:ASCII-8BIT>]

21.1 has that issue too.

@eregon
Copy link
Member

eregon commented Jul 5, 2021

@dentarg I tried to reproduce but the addressable specs pass for me locally.
Unclear why they failed in that CI run.

@eregon eregon added this to the 21.3.0 milestone Jul 5, 2021
graalvmbot pushed a commit that referenced this issue Jul 6, 2021
@eregon eregon modified the milestones: 21.3.0, 21.2.0 Jul 13, 2021
graalvmbot pushed a commit that referenced this issue Jul 13, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

4 participants