truffleruby
truffleruby copied to clipboard
Intermittent problem with Oj gem
Gemfile:
# frozen_string_literal: true
source 'https://rubygems.org'
gem 'rake', require: false
gem 'oj'
oj-test.rb
require 'oj'
for i in 1..10_000_000_000 do
puts Oj.load('{"Concerts":[{"ConcertId":"id-1"},{"ConcertId":"id-2"}]}', :mode=>:compat, :symbol_keys=>false, :empty_string=>false)
end
How to run
bundle exec ruby oj-test.rb
Eventually it will fail with:
/Users/novoi/.rubies/truffleruby-dev/lib/truffle/truffle/cext.rb:1115:in `rb_exc_raise': Hash/Object not terminated (after Concerts) at line 1, column 55 [parse.c:1151] in '{"Concerts":[{"ConcertId":"id-1"},{"ConcertId":"id-2"}]} (EncodingError)
from exception.c:29:in `rb_exc_raise'
from /Users/novoi/.rubies/truffleruby-dev/lib/gems/gems/oj-3.13.21/ext/oj/parse.c:1192:in `oj_pi_parse'
from /Users/novoi/.rubies/truffleruby-dev/lib/gems/gems/oj-3.13.21/ext/oj/compat.c:238:in `oj_compat_parse'
from /Users/novoi/.rubies/truffleruby-dev/lib/gems/gems/oj-3.13.21/ext/oj/oj.c:1070:in `load'
from /Users/novoi/.rubies/truffleruby-dev/lib/truffle/truffle/cext_ruby.rb:41:in `load'
from oj-test.rb:3:in `block in <main>'
from oj-test.rb:2:in `each'
from oj-test.rb:2:in `<main>'
Could be related to https://github.com/ohler55/oj/issues/293
Affected gems
aws-sdk-ruby
Thank you for the report. Can you also reproduce it on CRuby or only on TruffleRuby? It sounds like it could be an issue in Oj.
for CRuby I cannot reproduce it. Interestingly this test fails only when executed with bundle exec, so it could be combination of oj + bundle
Cannot reproduce the issue on the TruffleRuby master. Was waiting for 10M iterations and then stopped the script.