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

segfault requiring 'mysql2' gem on bionic #7851

Open
mmiller1 opened this Issue Nov 1, 2018 · 4 comments

Comments

Projects
None yet
3 participants
@mmiller1

mmiller1 commented Nov 1, 2018

Description

When attempting to install and require the mysql2 gem for use in a chef recipe, a segmentation fault occurs.

Chef Version

Chef: 14.6.47

Platform Version

Linux 4.15.0-1018-gcp #19-Ubuntu SMP Thu Aug 16 13:38:55 UTC 2018 x86_64 x86_64 x86_64 GNU/Linux

Replication Case

I reproduced the issue easily using chef-shell & the embedded gem binaries:

/opt/chef/embedded/bin/gem install mysql2
chef-shell -z
> require 'mysql2'
# observe segfault

https://gist.github.com/mmiller1/2473561eafa7d51a8a45c5805a5f1dda

Client Output

See gist above

I worked around this issue by replacing the libssl & libcrypto libraries with the versions shipped with ubuntu

mv /opt/chef/embedded/lib/libcrypto.so.1.0.0 /opt/chef/embedded/lib/libcrypto.so.1.0.0-bak
ln -s /usr/lib/x86_64-linux-gnu/libcrypto.so.1.0.0 /opt/chef/embedded/lib/libcrypto.so.1.0.0
mv /opt/chef/embedded/lib/libssl.so.1.0.0 /opt/chef/embedded/lib/libssl.so.1.0.0-bak
ln -s /usr/lib/x86_64-linux-gnu/libssl.so.1.0.0 /opt/chef/embedded/lib/libssl.so.1.0.0
/opt/chef/embedded/bin/gem uninstall mysql2
/opt/chef/embedded/bin/gem install mysql2
@wdeviers

This comment has been minimized.

wdeviers commented Nov 1, 2018

To add: if you "require 'mysql2'" from inside the IRB shipped with Chef, everything works as expected.

@lamont-granquist

This comment has been minimized.

Contributor

lamont-granquist commented Nov 2, 2018

/usr/lib/x86_64-linux-gnu/libssl.so.1.1(0x7f3666ddc708) [0x7f3666ddc708]
/lib/x86_64-linux-gnu/libpthread.so.0(__pthread_once_slow+0xb7) [0x7f3682d6f827]
/usr/lib/x86_64-linux-gnu/libcrypto.so.1.1(CRYPTO_THREAD_run_once+0x9) [0x7f3666ae2839]
/usr/lib/x86_64-linux-gnu/libssl.so.1.1(OPENSSL_init_ssl+0x8b) [0x7f3666ddc8eb]

so i have no idea why this works with the irb shipped inside of chef but you're linking against the libssl in your system, not the one from the openssl that is shipped in embedded which ruby is linked against.

in general in order to do this you need to install the mysql libs into embedded/lib linked against the underlying embedded libs first. then you can install the gem against that mysql library.

https://github.com/chef/chef-rfc/blob/master/rfc063-omnibus-chef-native-gems.md

that is an old RFC which has never been implemented in order to do that for everyone in omnibus-chef. nokogiri/libxml2/libxslt got done, but pg + mysql never got done.

probably going to wind up closing this because its not a bug in chef-client itself, its just a larger architectural issue inherent to omnibus builds.

@wdeviers

This comment has been minimized.

wdeviers commented Nov 6, 2018

I don't want to put words into your mouth, but does that imply we should stop using the omnibus installer on 18.04?

@lamont-granquist

This comment has been minimized.

Contributor

lamont-granquist commented Nov 7, 2018

no, that'd be worse.

ideally there would be a cookbook that would install it correctly, but looking around the mysql_chef_gem/mysql_chef_gem2 cookbooks it doesn't seem like i can find one that does the necessary magic to correctly install the mysql libs.

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