3

We have an older REE rails app that I work on my local dev environment in OSX Yosemite. I recently switched from Mavericks, with which I had no problems. I ran this app for the first time on my new work mac and found I was unable to login due to it throwing a segment fault error and quitting the local webrick server. After some investigation, I found the culprit:

digest = Digest::SHA512.hexdigest('some_arbitrary_value')

On further investigation, I found that this line of code throws the following error:

[BUG] Segmentation fault
ruby 1.8.7 (2013-06-27 MBARI 8/0x6770 on patchlevel 374) [i686-darwin14.3.0], MBARI 0x6770, Ruby Enterprise Edition 2012.02

...and quits the ruby console.

Both ruby versions 1.8.7 and REE produce this issue on my OSX Yosemite machine. Ruby versions 1.9.3 and newer seem to produce the expected hash without error.

Why does Digest::SHA512.hexdigest produce a [BUG] Segmentation fault error after switching from OSX Mavericks to Yosemite?

RNickMcCandless
  • 717
  • 2
  • 9
  • 24
  • This isn't the solution, but my temporary workaround for this so that I could complete my urgent task without having to actually solve the problem is to change 512 to 256 in that line of code. Note that anything encrypted with 512 will no longer match anything you encrypt now, but in my case I could easily reset a password and login to continue development. – cesoid Jul 21 '15 at 19:28

3 Answers3

8

I had the same problem with version ree-1.8.7-2012.02 of ruby and Max OS X Yosemite, and as all of the solutions I found on the internet doesn't work for me, after some tests I found a solution.

You only have to change Digest::SHA512.hexdigest(digest) to OpenSSL::Digest::SHA512.new(digest).hexdigest and it will work fine.

It's a little inconvenience because you have to change the code all over your application, but as last resource it works.

Iván González
  • 149
  • 3
  • 6
  • Thanks for this solution it saved me a serious headache. But, I had to go into a third party gem and change their code (authlogic). Is there any alternative to this that you know of? – userFriendly Oct 22 '15 at 16:50
  • The gem with which I had that problem was Authlogic too! Specifically with encrypt method of class CryptoProviders::Authlogic::SHA512. In his day I did nothing more than the change in my answer (change on the gem the code as a temp solution), but I guess through a decorator you can redefine the method to use OpenSSL::Digest::SHA512. If you try it and works, let me know! :) – Iván González Oct 24 '15 at 14:38
1

Solution:

You need to ensure that ruby is built using an older version of openssl.

I downloaded the 0.9.8 openssl into a directory (~/builds/openssl-0.9.8zg), built it but did NOT install it. When you install a version of ruby, point rvm to the openssl 0.9.8 directory

rvm reinstall 1.8.7-p374 --autolibs=0 --with-openssl=~/builds/openssl-0.9.8zg

This has worked for me and rails 2.3.18 now fires up and runs under Yosemite.

0

I don't have an answer, but have exactly the same issue.

Interestingly I am moving from a Mac running Yosemite to a brand new Mac also running Yosemite. The old mac does NOT have the seg fault issue. Both machines are using Yosemite, rvm, ruby 1.8.7

But I have noticed that 'new mac' uses openssl 1.0.2c 12 Jun 2015 and 'old mac' uses openssl 1.0.1c 10 May 2012

Could it be something to do with the version of SSL libraries being compiled against?

Sorry for not providing an answer but thought this was worth mentioning in case it helps.

I am continuing to investigate and will report any success here.

Update:

'old mac'

ruby -ropenssl -e 'puts OpenSSL::OPENSSL_VERSION'

reports OpenSSL 0.9.8r 8 Feb 2011

'new mac' reports OpenSSL 1.0.2c 12 Jun 2015