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

[Ruby] Message#hash crashes with a C assertion on Windows #8564

Closed
dazuma opened this issue May 5, 2021 · 0 comments · Fixed by #8565
Closed

[Ruby] Message#hash crashes with a C assertion on Windows #8564

dazuma opened this issue May 5, 2021 · 0 comments · Fixed by #8565

Comments

@dazuma
Copy link
Contributor

dazuma commented May 5, 2021

What version of protobuf and what language are you using?
Version: 3.15.8
Language: Ruby 2.7.3, 3.0.1

What operating system (Linux, Windows, ...) and version?
Windows Server 2019 (10.0.17763), via the "windows-latest" platform on GitHub Actions.

What runtime / compiler are you using (e.g., python version or gcc version)
n/a (using the binary gem release)

What did you do?

require "google/protobuf"

Google::Protobuf::DescriptorPool.generated_pool.build do
  add_file("windoze.proto", :syntax => :proto3) do
    add_message "windoze.SimpleTest" do
      # Note: No fields necessary
    end
  end
end
module Windoze
  SimpleTest = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("windoze.SimpleTest").msgclass
end

message = Windoze::SimpleTest.new
puts message.hash

What did you expect to see
An integer hash value displayed

What did you see instead?
The Ruby VM terminates with the following assertion coming from C code:

[BUG] Unnormalized Fixnum value 0xbb5cc1f7724449a5

Anything else we should know about your project / environment

I found this while investigating #8554. The assertion is coming from here and seems to happen if the value claims to be a Fixnum but doesn't fall within the range of the long type. Thus, it could trigger on 64-bit Windows where longs are 32 bits, if the Fixnum is set from a 64-bit value. This is indeed the case in Message_hash, which takes a 64-bit integer from wyhash, and crams it directly into INT2FIX.

This does not seem to trigger on Linux or MacOS, which is unsurprising because long is 64-bit on those platforms.

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 a pull request may close this issue.

1 participant