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

Seg fault with statically linked version of Ruby #54

Open
jkehres opened this issue May 22, 2021 · 4 comments
Open

Seg fault with statically linked version of Ruby #54

jkehres opened this issue May 22, 2021 · 4 comments
Assignees
Labels
🐞 bug Something isn't working

Comments

@jkehres
Copy link

jkehres commented May 22, 2021

Describe the bug

I'm using a statically linked version of Ruby 2.7.2 on macOS. I can build the gem (it links against libruby.2.7-static.a) but when I require the gem, I get a seg fault at lib/wasmer.rb:31. If I use a dynamically linked version of Ruby 2.7.2 (where the gem links against libruby.2.7.dylib) everything works fine.

Steps to reproduce

  1. On a Mac, build a statically linked version of Ruby 2.7.2 (e.g. RUBY_CONFIGURE_OPTS="--disable-shared" ruby-build 2.7.2 /path/to/install)
  2. Verify that /path/to/install/lib contains libruby.2.7-static.a
  3. Build the gem against this version of Ruby
  4. Open an IRB session
  5. Run require 'wasmer'

Expected behavior

No seg fault occurs.

Actual behavior

Seg fault occurs.

Additional context

Repeating the same steps with RUBY_CONFIGURE_OPTS="--enabled-shared" works just fine.

@jkehres jkehres added the 🐞 bug Something isn't working label May 22, 2021
@Hywan
Copy link
Contributor

Hywan commented May 25, 2021

Hello,

We use rutie to build this extension. Reading its documentation (https://github.com/danielpclark/rutie#dynamic-vs-static-builds):

Dynamic vs Static Builds

Ruby needs to be compiled with the --enable-shared option. Dynamic linking to the Ruby library provides the best performance and best support. Static build support is incomplete for now.

If using RBENV then the following is recommended:

CONFIGURE_OPTS=--enable-shared rbenv install 2.7.1

I'm sad to say that either you must use the dynamic library, or we need to contribute to rutie to fix the issues.

@Hywan Hywan self-assigned this May 25, 2021
@Hywan
Copy link
Contributor

Hywan commented May 25, 2021

Note: We must at least test that Ruby is compiled with the --enable-shared option to raise an approriate error message rather than a segfault. We may be able to find this information with RbConfig::CONFIG['ENABLE_SHARED']. Are you willing to open a PR for that (just asking)?

@sandstrom
Copy link

For future reference, here are the relevant issues in rutie: https://github.com/danielpclark/rutie/issues?q=is%3Aissue+is%3Aopen+label%3A%22static+build+issue%22

And here is a similar (now closed) issue in wasmer-ruby: #56

@Hywan
Copy link
Contributor

Hywan commented Jun 18, 2021

Thanks :-)!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🐞 bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants