[#108552] [Ruby master Bug#18782] Race conditions in autoload when loading the same feature with multiple threads. — "ioquatix (Samuel Williams)" <noreply@...>
Issue #18782 has been reported by ioquatix (Samuel Williams).
11 messages
2022/05/14
[ruby-core:108492] [Ruby master Bug#18766] ArgumentError with no backtrace information when requiring openssl/cipher and initializing an OpenSSL::Cipher
From:
"Hanmac (Hans Mackowiak)" <noreply@...>
Date:
2022-05-09 12:19:10 UTC
List:
ruby-core #108492
Issue #18766 has been updated by Hanmac (Hans Mackowiak).
@postmodern : the problem is a missing require
`openssl/cipher` is a helper script that can't run without `openssl` or it makes funky results
```
irb(main):001:0> require "openssl/cipher"
=> true
irb(main):002:0> OpenSSL::Cipher.new('aes-256-cbc')
(irb):2:in `initialize': wrong number of arguments (given 1, expected 0) (ArgumentError)
from (irb):2:in `new'
from (irb):2:in `<main>'
from C:/Ruby31-x64/lib/ruby/gems/3.1.0/gems/irb-1.4.1/exe/irb:11:in `<top (required)>'
from C:/Ruby31-x64/bin/irb:33:in `load'
from C:/Ruby31-x64/bin/irb:33:in `<main>'
irb(main):003:0> OpenSSL::Cipher.new()
=> #<OpenSSL::Cipher:0x000001f0d93d2518>
irb(main):004:0> require "openssl"
=> true
irb(main):005:0> OpenSSL::Cipher.new('aes-256-cbc')
=> #<OpenSSL::Cipher:0x000001f0d963ae40>
irb(main):006:0> c= OpenSSL::Cipher.new('aes-256-cbc')
=> #<OpenSSL::Cipher:0x000001f0d8f5c218>
irb(main):007:0> c.name
=> "AES-256-CBC"
irb(main):008:0> c= OpenSSL::Cipher.new()
(irb):8:in `initialize': wrong number of arguments (given 0, expected 1) (ArgumentError)
```
you should just require `openssl` instead, because it does already require `cipher` too
----------------------------------------
Bug #18766: ArgumentError with no backtrace information when requiring openssl/cipher and initializing an OpenSSL::Cipher
https://bugs.ruby-lang.org/issues/18766#change-97536
* Author: postmodern (Hal Brodigan)
* Status: Open
* Priority: Normal
* ruby -v: ruby 3.1.2p20 (2022-04-12 revision 4491bb740a) [x86_64-linux]
* Backport: 2.7: UNKNOWN, 3.0: UNKNOWN, 3.1: UNKNOWN
----------------------------------------
I discovered a mysterious ArgumentError when requiring 'openssl/cipher' instead of 'openssl' and initializing a OpenSSL::Cipher object. The ArgumentError does not indicate where the exception is being raised from.
## Steps To Reproduce
```
ruby -r openssl/cipher -e "p OpenSSL::Cipher.new('aes-256-cbc')"
```
## Expected Result
```
#<OpenSSL::Cipher:0x000055a5424cef68>
```
## Actual Result
```
Traceback (most recent call last):
2: from -e:1:in `<main>'
1: from -e:1:in `new'
-e:1:in `initialize': wrong number of arguments (given 1, expected 0) (ArgumentError)
```
## Effected Versions
Can reproduce this bug using ruby-2.7 and ruby-3.1.
--
https://bugs.ruby-lang.org/
Unsubscribe: <mailto:ruby-core-request@ruby-lang.org?subject=unsubscribe>
<http://lists.ruby-lang.org/cgi-bin/mailman/options/ruby-core>