Digest::SHA256.hexdigest failing with the digest/sha1

A

a.grushin

Hello, all

a have a program which is used Digest::SHA256.hexdigest, but it is failing on a few machines with 'Illegal instruction' error:

$ ruby -v
ruby 1.8.7 (2012-10-12 patchlevel 371) [x86_64-linux]
$ irb
irb(main):001:0> require 'digest/sha1'
=> true
irb(main):002:0> puts Digest::SHA256.hexdigest("123")
Illegal instruction

Perhaps something wrong with packages, but I'm not sure how to find the root cause.

brokenbox # strace ruby 1.rb
[...]
stat("/usr/lib64/site_ruby/digest.so", 0x7fff5e3bc9b0) = -1 ENOENT (No such file or directory)
stat("/usr/lib/ruby/1.8/digest.rb", {st_mode=S_IFREG|0644, st_size=1145, ...}) = 0
open("/usr/lib/ruby/1.8/digest.rb", O_RDONLY) = 3
fstat(3, {st_mode=S_IFREG|0644, st_size=1145, ...}) = 0
close(3) = 0
--- SIGILL (Illegal instruction) @ 0 (0) ---
+++ killed by SIGILL +++

strace on the good box show following:

goodbox # strace ruby 1.rb
[...]
stat("/usr/lib64/site_ruby/digest.so", 0x7fffa8dc2860) = -1 ENOENT (No such file or directory)
stat("/usr/lib/ruby/1.8/digest.rb", {st_mode=S_IFREG|0644, st_size=1145, ...}) = 0
open("/usr/lib/ruby/1.8/digest.rb", O_RDONLY) = 3
fstat(3, {st_mode=S_IFREG|0644, st_size=1145, ...}) = 0
close(3) = 0
fstat(1, {st_mode=S_IFCHR|0620, st_rdev=makedev(136, 0), ...}) = 0
mmap(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7fe9a0d8f000
write(1, "a665a45920422f9d417e4867efdc4fb8"..., 65a665a45920422f9d417e4867efdc4fb8a04a1f3fff1fa07e998e86f7f7a27ae3
) = 65
rt_sigaction(SIGINT, {SIG_DFL, [INT], SA_RESTORER|SA_RESTART, 0x7fe99fa2c900}, {0x7fe9a0902910, [], SA_RESTORER, 0x7fe9a06604a0}, 8) = 0
exit_group(0) = ?

Could anybody help me with advice how to investigate this issue?

This can be solved with a simple recreating those hosts, but this is interesting to find the reason.

Thanks!
 
R

Robert Klemme

a have a program which is used Digest::SHA256.hexdigest, but it is failing on a few machines with 'Illegal instruction' error:

It may be related to the fact that your version is ancient:
$ ruby -v
ruby 1.8.7 (2012-10-12 patchlevel 371) [x86_64-linux]
http://www.ruby-lang.org/en/news/2011/10/06/plans-for-1-8-7/

Perhaps something wrong with packages, but I'm not sure how to find the root cause.

I would start by ensuring that all packages are current on the system. Hopefully nobody has messed with package repositories on that box. I guess then all bets are off...

Kind regards

robert
 
J

Julian Cromarty

a have a program which is used Digest::SHA256.hexdigest, but it is failing on a few machines with 'Illegal instruction' error:

It may be related to the fact that your version is ancient:
$ ruby -v
ruby 1.8.7 (2012-10-12 patchlevel 371) [x86_64-linux]

From my experience, the most common reason for an "Illegal Instruction"
error is mismatched/incorrect library/executable architectures.

I would check that you haven't accidentally got a mixture of x86 and
x86_64 packages in your Ruby installation (or that you're not
accidentally running an x86_64 packages on an x86 machine).

If that's all correct then check the output of ldd when you run it on
both the Ruby executable and the digest.so library and ensure that
everything listed is for the correct architecture for the machines
you're running on.

Good luck :)

Julian
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,744
Messages
2,569,482
Members
44,901
Latest member
Noble71S45

Latest Threads

Top