You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I'm trying to run google-protobuf on TruffleRuby. The gem contains a C extension that computes a hash code off of Ruby strings, and TruffleRuby does not execute the hash function correctly.
This is fixed with 9a22abd and 1bf2f6a, by always returning a native pointer for RSTRING_PTR. It will be in the 20.0 release. Thank you for the bug report!
I'm trying to run google-protobuf on TruffleRuby. The gem contains a C extension that computes a hash code off of Ruby strings, and TruffleRuby does not execute the hash function correctly.
I have reduced the code down to a simple demo extension here that you can play with: https://gist.github.com/XrXr/d7a07623330c244cb3b13bcae5f9530e.
As you can see in the output, TruffleRuby reads out a single byte instead of the expected four.
The hash function in protobuf is here: https://github.com/protocolbuffers/protobuf/blob/c08b7512cf9d65899e8e84edd02d4335a64b11b0/ruby/ext/google/protobuf_c/upb.c#L2007
Digging into the code RSTRING_PTR returns a polyglot object, which only supports single byte loads:
truffleruby/lib/truffle/truffle/cext.rb
Line 164 in 3541dce
truffleruby/src/main/java/org/truffleruby/cext/CExtNodes.java
Line 1063 in 25e3533
Related, Sulong computes the index into the polyglot object in an undesirable way:
https://github.com/oracle/graal/blob/cbee70bd6f3e0c487e1340ace299eb3813596922/sulong/projects/com.oracle.truffle.llvm.runtime/src/com/oracle/truffle/llvm/runtime/interop/access/LLVMInteropReadNode.java#L72
The division makes it so that the byte being read out in a multiple-byte load isn't necessarily the byte at that address.
The text was updated successfully, but these errors were encountered: