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

Strange segfault on M1 Mac...? #477

Closed
ioquatix opened this issue Dec 10, 2021 · 9 comments
Closed

Strange segfault on M1 Mac...? #477

ioquatix opened this issue Dec 10, 2021 · 9 comments
Assignees
Labels

Comments

@ioquatix
Copy link
Member

> irb
irb(main):001:0> require 'openssl'
=> true
irb(main):002:0> certificate = OpenSSL::X509::Certificate.new
=> #<OpenSSL::X509::Certificate subject=#<OpenSSL::X509::Name >, issuer=#<OpenSSL::X509::Name >, serial=#<OpenSSL::BN 0>, not_before=nil, not_after=nil>
irb(main):003:0> certificate_authority_key = OpenSSL::PKey::RSA.new(2048)
=> #<OpenSSL::PKey::RSA:0x000000010bafc358 oid=rsaEncryption>
irb(main):004:0> certificate.public_key = certificate_authority_key.public_key
(irb):4: [BUG] Segmentation fault at 0x0000000000000028
ruby 3.1.0dev (2021-12-10T10:09:55Z master 0e60bc118b) [arm64-darwin21]    

Am I doing something wrong? Running on latest Ruby head.

@ioquatix
Copy link
Member Author

Thread 0 Crashed::  Dispatch queue: com.apple.main-thread
0   libsystem_kernel.dylib        	       0x18c36d9b8 __pthread_kill + 8
1   libsystem_pthread.dylib       	       0x18c3a115c pthread_kill + 288
2   libsystem_c.dylib             	       0x18c2de314 abort + 164
3   ruby                          	       0x104fcd020 die + 12 (error.c:783)
4   ruby                          	       0x104fcd1f0 rb_bug_for_fatal_signal + 464 (error.c:824)
5   ruby                          	       0x1050f0ce8 sigsegv + 96 (signal.c:964)
6   libsystem_platform.dylib      	       0x18c3b84e4 _sigtramp + 56
7   openssl.bundle                	       0x109d9f15c ossl_pkey_check_public_key + 144 (ossl_pkey.c:405)
8   openssl.bundle                	       0x109db3b68 ossl_x509_set_public_key + 56 (ossl_x509cert.c:524)
9   ruby                          	       0x105180980 vm_call_cfunc_with_frame + 232 (vm_insnhelper.c:3041)
10  ruby                          	       0x105182f80 vm_sendish + 1324
11  ruby                          	       0x1051641e4 vm_exec_core + 10320 (insns.def:778)
12  ruby                          	       0x105177d24 rb_vm_exec + 2648

@ioquatix
Copy link
Member Author

Confirmed working 3.0.2 and 3.0.3

require 'openssl'

certificate = OpenSSL::X509::Certificate.new
certificate_authority_key = OpenSSL::PKey::RSA.new(2048)

certificate.public_key = certificate_authority_key.public_key

@ioquatix ioquatix added the bug label Dec 10, 2021
@ioquatix ioquatix removed their assignment Dec 10, 2021
@ioquatix
Copy link
Member Author

I tried using MacPorts OpenSSL:

> ../configure --with-openssl-dir=/opt/local/lib/openssl-1.1/ --prefix=/Users/samuel/.rubies/ruby-head

But it still failed.

@rhenium
Copy link
Member

rhenium commented Dec 10, 2021

7 openssl.bundle 0x109d9f15c ossl_pkey_check_public_key + 144 (ossl_pkey.c:405)

Is this with OpenSSL 3.0? A segfault here is expected in that case.

#399 78a8eeb

@ioquatix
Copy link
Member Author

irb(main):002:0> OpenSSL::VERSION
=> "3.0.0.pre"

Is that what you mean?

@ioquatix
Copy link
Member Author

Hm,

> OpenSSL::OPENSSL_VERSION
=> "OpenSSL 3.0.0 7 sep 2021"
> OpenSSL::OPENSSL_LIBRARY_VERSION
=> "OpenSSL 3.0.0 7 sep 2021"

@rhenium
Copy link
Member

rhenium commented Dec 10, 2021

No, I meant the OpenSSL library's version (libcrypto) that ruby/openssl is linked with.

I tried using MacPorts OpenSSL:

> ../configure --with-openssl-dir=/opt/local/lib/openssl-1.1/ --prefix=/Users/samuel/.rubies/ruby-head

But it still failed.

It's strange if this still happens with OpenSSL <= 1.1.1. Do you have backtrace with this? I don't own M1 Mac so I can't reproduce it myself.

@ioquatix
Copy link
Member Author

It seems like configure is not using the right OpenSSL version.

@ioquatix
Copy link
Member Author

Okay, as you suggested, I needed this:

../configure --with-openssl-include=/opt/local/include/openssl-1.1 --with-openssl-lib=/opt/local/lib/openssl-1.1 --prefix=/Users/samuel/.rubies/ruby-head

Otherwise it picks the wrong OpenSSL version.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Development

No branches or pull requests

2 participants