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

sqlite gem tests failing on truffleruby-head #3352

Closed
flavorjones opened this issue Dec 9, 2023 · 3 comments
Closed

sqlite gem tests failing on truffleruby-head #3352

flavorjones opened this issue Dec 9, 2023 · 3 comments
Assignees

Comments

@flavorjones
Copy link
Contributor

Tests pass with truffleruby-23.1.1, but error on truffleruby-dev (v24.0.0-dev-070598d4).

See https://github.com/sparklemotion/sqlite3-ruby/actions/runs/7111938537/job/19478241596#step:7:47

1) Error:
SQLite3::TestDatabase#test_bignum:
RuntimeError: Neutered Exception Polyglot::ForeignException: Message not supported.
    integer.c:89:in `rb_integer_pack'
    /home/runner/.rubies/truffleruby-head/lib/truffle/truffle/cext_ruby.rb:40:in `<unknown>'
    /home/runner/.rubies/truffleruby-head/lib/truffle/truffle/cext_ruby.rb:40:in `<unknown>'
    /home/runner/.rubies/truffleruby-head/lib/truffle/truffle/cext_ruby.rb:40:in `SQLite3::Statement#bind_param'
    /home/runner/work/sqlite3-ruby/sqlite3-ruby/lib/sqlite3/statement.rb:41:in `block in SQLite3::Statement#bind_params'
    /home/runner/work/sqlite3-ruby/sqlite3-ruby/lib/sqlite3/statement.rb:37:in `Array#each'
    /home/runner/work/sqlite3-ruby/sqlite3-ruby/lib/sqlite3/statement.rb:37:in `SQLite3::Statement#bind_params'
    /home/runner/work/sqlite3-ruby/sqlite3-ruby/lib/sqlite3/database.rb:222:in `block in SQLite3::Database#execute'
    /home/runner/work/sqlite3-ruby/sqlite3-ruby/lib/sqlite3/database.rb:181:in `SQLite3::Database#prepare'
    /home/runner/work/sqlite3-ruby/sqlite3-ruby/lib/sqlite3/database.rb:2[21](https://github.com/sparklemotion/sqlite3-ruby/actions/runs/7111938537/job/19478241596#step:7:22):in `SQLite3::Database#execute'
    /home/runner/work/sqlite3-ruby/sqlite3-ruby/test/test_database.rb:86:in `SQLite3::TestDatabase#test_bignum'

Test in question is:

    def test_bignum
      num = 4907021672125087844
      db.execute 'CREATE TABLE "employees" ("token" integer(8), "name" varchar(20) NOT NULL)'
      db.execute "INSERT INTO employees(name, token) VALUES('employee-1', ?)", [num]
      rows = db.execute 'select token from employees'
      assert_equal num, rows.first.first
    end

(the exception is thrown from the INSERT statement)

I haven't bisected, but looking at the git log, 8404d4f jumps out to me as a possible commit for introducing this behavior change.

@eregon eregon self-assigned this Dec 11, 2023
@eregon
Copy link
Member

eregon commented Dec 11, 2023

Thank you for the report.
It is indeed likely related to that commit or at least to the Fixnum limit.
I have also reviewed all other similar cases and fixed them.

@eregon
Copy link
Member

eregon commented Dec 11, 2023

Fix in #3354.

BTW here is some context: it used to be that TruffleRuby declared Fixnum to be the entire signed 64-bit long range ([-2**63,2**63[) since Java long is used internally, but that doesn't really work in the C API because there is some expectation that all fixnums can be represented as tagged pointers and so have 1 less bit.
So then in the C API there are 3 cases, fit in Fixnum ([-2**62,2**62]), real Bignum (|x|>2**63) and "in-between" which is what we hit here, which is represented as a long in Java but is not a Fixnum from the C API POV.
So the fix changes how to call a method on such a long, which is not a Ruby object from the interop POV but an interop primitive (which has no language).

@flavorjones
Copy link
Contributor Author

Thank you!

eregon added a commit to ruby/spec that referenced this issue Feb 5, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants