Issue #4320 has been updated by Nils Goroll.


This indeed is an alignment issue, SHA256_Update calls SHA256_Transform with possibly unaligned data, but the latter needs its data argument be aligned on platforms which do not support unaligned word access. The same bug exists for SHA384 and SHA512

I have a fix ready, currently testing it.

here's a failing test case for SHA512, which will also hit for SHA384 (which uses the same code).

 > ruby -e "require 'digest/sha2'; d= Digest::SHA512.new; ['a' * 57, 'b' * 199].each {|i| d.update(i)}; p d"
 -e:1: [BUG] Bus Error
 ruby 1.9.2p136 (2010-12-25 revision 30365) [sparc-solaris2.10]
 
 -- control frame ----------
 c:0007 p:---- s:0019 b:0019 l:000018 d:000018 CFUNC  :update
 c:0006 p:0014 s:0015 b:0015 l:001504 d:000014 BLOCK  -e:1
 c:0005 p:---- s:0012 b:0012 l:000011 d:000011 FINISH
 c:0004 p:---- s:0010 b:0010 l:000009 d:000009 CFUNC  :each
 c:0003 p:0054 s:0007 b:0007 l:001504 d:000db0 EVAL   -e:1
 c:0002 p:---- s:0004 b:0004 l:000003 d:000003 FINISH
 c:0001 p:0000 s:0002 b:0002 l:001504 d:001504 TOP   
 ---------------------------
 -- Ruby level backtrace information ----------------------------------------
 -e:1:in `<main>'
 -e:1:in `each'
 -e:1:in `block in <main>'
 -e:1:in `update'
 
 [NOTE]
 You may have encountered a bug in the Ruby interpreter or extension libraries.
 Bug reports are welcome.
 For details: http://www.ruby-lang.org/bugreport.html
 
 Abort (core dumped)

----------------------------------------
Bug #4320: Bus Error in digest/sha2 on sparc
http://redmine.ruby-lang.org/issues/4320

Author: Meik Nienaber
Status: Assigned
Priority: Normal
Assignee: Akinori MUSHA
Category: 
Target version: 1.9.2
ruby -v: ruby 1.9.2p136 (2010-12-25 revision 30365) [sparc-solaris2.10]


 Most likely this is caused due to misaligned memory. Any comment is greatly appreciated.
 
 This bug can reproduce at Ruby 1.8, too.
 
 ruby -e "require 'digest/sha2'; d= Digest::SHA256.new; ['a' * 97, 'a' * 97].each {|i| d.update(i)}; p d"
 -e:1: [BUG] Bus Error
 ruby 1.9.2p136 (2010-12-25 revision 30365) [sparc-solaris2.10]
 
 -- control frame ----------
 c:0007 p:---- s:0019 b:0019 l:000018 d:000018 CFUNC  :update
 c:0006 p:0014 s:0015 b:0015 l:0015ac d:000014 BLOCK  -e:1
 c:0005 p:---- s:0012 b:0012 l:000011 d:000011 FINISH
 c:0004 p:---- s:0010 b:0010 l:000009 d:000009 CFUNC  :each
 c:0003 p:0054 s:0007 b:0007 l:0015ac d:000ed0 EVAL   -e:1
 c:0002 p:---- s:0004 b:0004 l:000003 d:000003 FINISH
 c:0001 p:0000 s:0002 b:0002 l:0015ac d:0015ac TOP


-- 
http://redmine.ruby-lang.org