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

Implement C API methods for OpenSSL 2.2.1 #2524

Closed
nirvdrum opened this issue Nov 7, 2021 · 2 comments
Closed

Implement C API methods for OpenSSL 2.2.1 #2524

nirvdrum opened this issue Nov 7, 2021 · 2 comments
Assignees
Labels
Milestone

Comments

@nirvdrum
Copy link
Collaborator

nirvdrum commented Nov 7, 2021

It's not possible to install OpenSSL 2.2.1 with any released version of TruffleRuby or with the current dev version. This will show up as an error about rb_str_locktmp not being implemented:

ERROR:  While executing gem ... (RuntimeError)
    External LLVMFunction rb_str_locktmp cannot be found. (com.oracle.truffle.llvm.runtime.except.LLVMLinkerException)

The relevant commit in the OpenSSL extension is ruby/openssl@d382749. The full set of changes is ruby/openssl@v2.2.0...v2.2.1. It looks like in addition to rb_str_locktmp we'll need to handle rb_str_unlocktmp and store the boolean flag that the pair of functions adjusts.

@eregon eregon added the cexts label Nov 8, 2021
@eregon
Copy link
Member

eregon commented Nov 8, 2021

The repro is actually a bit more complex, installing openssl 2.2.1 works fine, but then using it breaks:

$ gem i openssl:2.2.1
$ gem i json
ERROR:  While executing gem ... (RuntimeError)
    External LLVMFunction rb_str_locktmp cannot be found. (com.oracle.truffle.llvm.runtime.except.LLVMLinkerException)
Translated to internal error

openssl is a default gem so the latest version is always picked (unless running under bundler, but e.g. bundle install is not run under bundler)

@bjfish Could you look to support those 2 functions?
We should implement rb_str_locktmp, rb_str_unlocktmp and check that boolean flag (we can store it in RubyString) in methods which mutate the string.
We could have Primitive.check_mutable_string (instead of Primitive.check_frozen) and raiseIfNotMutable instead of raiseIfFrozenSelf for String methods & nodes.

I had a quick look at CRuby code for these functions, and it seems they prevent mutation even for the thread which "locked" the String, but we should verify that is indeed the behavior with C-API specs.
So if I got it right, it's basically the same as a temporary .freeze + unfreeze but with a different error message, and only for Strings.

@bjfish
Copy link
Contributor

bjfish commented Nov 9, 2021

@nirvdrum This is now implemented at de75026.

@bjfish bjfish closed this as completed Nov 9, 2021
@bjfish bjfish added this to the 22.0.0 milestone Nov 9, 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

3 participants