Skip Menu |

This queue is for tickets about the Digest-SHA CPAN distribution.

Report information
The Basics
Id: 96498
Status: resolved
Priority: 0/
Queue: Digest-SHA

People
Owner: Nobody in particular
Requestors: GAAS [...] cpan.org
Cc:
AdminCc:

Bug Information
Severity: (no value)
Broken in:
  • 5.91
  • 5.92
  • 5.90
Fixed in: 5.93



Subject: hmac_sha384("", "") crashes on HP-UX IA.64
This cause the woodbury test to fail like this:

-bash-4.2$ perl -Mblib t/woodbury.t
1..21
ok 1
ok 2
ok 3
ok 4
ok 5
ok 6
ok 7
Bus error (core dumped)

In gdb I see this:

-bash-4.2$ gdb32 perl-debugging
HP gdb 3.4 for PA-RISC 1.1 or 2.0 (narrow), HP-UX 11.00.
Copyright 1986 - 2001 Free Software Foundation, Inc.
Hewlett-Packard Wildebeest 3.4 (based on GDB) is covered by the
GNU General Public License. Type "show copying" to see the conditions to
change it and/or distribute copies. Type "show warranty" for warranty/support.
..
Detected IPF executable.
Invoking /opt/langtools/bin/gdb
Use "run" to continue execution
(no debugging symbols found)...(gdb) run -Mblib -MDigest::SHA=hmac_sha384 -e 'hmac_sha384("", "")'
 
Starting program: /home/gecko/apeeX1/bin/perl-debugging -Mblib -MDigest::SHA=hmac_sha384 -e 'hmac_sha384("", "")'
(no debugging symbols found)...(no debugging symbols found)...
(no debugging symbols found)...(no debugging symbols found)...
(no debugging symbols found)...(no debugging symbols found)...
(no debugging symbols found)...(no debugging symbols found)...
(no debugging symbols found)...(no debugging symbols found)...
(no debugging symbols found)...(no debugging symbols found)...
(no debugging symbols found)...(no debugging symbols found)...
(no debugging symbols found)...
Program received signal SIGBUS, Bus error (si_code: 1).
warning: No unwind information found.
 Skipping this library /usr/lib/hpux32/libcl.so.1.
 
0x200000007e813d40:1 in sha512 (s=0x7fffed2c,
    block=0x7fffef2c '\\' <repeats 128 times>) at src/sha64bit.c:105
105             a = H[0]; b = H[1]; c = H[2]; d = H[3];
(gdb)


-bash-4.2$ perl -V
Summary of my perl5 (revision 5 version 12 subversion 5) configuration:
 
  Platform:
    osname=hpux, osvers=11.23, archname=IA64.ARCHREV_0-thread-multi
    uname='hp-ux bugaboo b.11.23 u ia64 3532919469 unlimited-user license '
    config_args='-ders -Dcc=cc -Dusethreads -Duseithreads -Uinstallusrbinperl -Ulocincpth= -Uloclibpth= -Ud_sigsetjmp -Dsh=/usr/bin/sh -Dd_attribut=undef -Dd_attribute_warn_unused_result=undef -Dd_u32align=define -Aprepend:libswanted=cl  -Accflags=+DSitanium2 -Doptimize=-fast +Ofltacc=strict -Accflags=+Z -Accflags=-DUSE_SITECUSTOMIZE -Duselargefiles -Dprefix=/home/gecko/apeeX1 -Dprivlib=/home/gecko/apeeX1/lib -Darchlib=/home/gecko/apeeX1/lib -Dsiteprefix=/home/gecko/apeeX1/site -Dsitelib=/home/gecko/apeeX1/site/lib -Dsitearch=/home/gecko/apeeX1/site/lib -Dsed=/usr/bin/sed -Duseshrplib -Dcf_by=ActiveState -Dcf_email=support@ActiveState.com'
    hint=recommended, useposix=true, d_sigaction=define
    useithreads=define, usemultiplicity=define
    useperlio=define, d_sfio=undef, uselargefiles=define, usesocks=undef
    use64bitint=undef, use64bitall=undef, uselongdouble=undef
    usemymalloc=n, bincompat5005=undef
  Compiler:
    cc='cc', ccflags =' -D_POSIX_C_SOURCE=199506L -D_REENTRANT -Ae -D_HPUX_SOURCE -Wl,+vnocompatwarnings +DSitanium2 +Z -DUSE_SITECUSTOMIZE -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64 ',
    optimize='-fast +Ofltacc=strict',
    cppflags='-D__STDC_EXT__ -D_HPUX_SOURCE -D_POSIX_C_SOURCE=199506L -D_REENTRANT -D_HPUX_SOURCE -Wl,+vnocompatwarnings -DUSE_SITECUSTOMIZE'
    ccversion='B3910B A.05.55', gccversion='', gccosandvers=''
    intsize=4, longsize=4, ptrsize=4, doublesize=8, byteorder=4321
    d_longlong=define, longlongsize=8, d_longdbl=define, longdblsize=16
    ivtype='long', ivsize=4, nvtype='double', nvsize=8, Off_t='off_t', lseeksize=8
    alignbytes=8, prototype=define
  Linker and Libraries:
    ld='/usr/bin/ld', ldflags =' -L/usr/lib/hpux32'
    libpth=/usr/lib/hpux32 /lib /usr/lib /usr/ccs/lib /usr/local/lib
    libs=-lcl -lnsl -lnm -lndbm -ldl -ldld -lm -lsec -lpthread -lc
    perllibs=-lcl -lnsl -lnm -ldl -ldld -lm -lsec -lpthread -lc
    libc=/usr/lib/hpux32/libc.so, so=so, useshrplib=true, libperl=libperl.so
    gnulibc_version=''
  Dynamic Linking:
    dlsrc=dl_hpux.xs, dlext=so, d_dlsymun=undef, ccdlflags='-Wl,-E -Wl,-B,deferred '
    cccdlflags='+Z', lddlflags='-b +vnocompatwarnings -L/usr/lib/hpux32'

Sorry about all the noise.  I've now tried to compile older versions of Digest-SHA and can tell you that this breakage was introduced in version 5.90.  In 5.89 hmac_sha384("", "") runs to completion without bus error.
I ran into the same and I found a workaround, which I applied to the Perl 5 git repo: http://perl5.git.perl.org/perl.git/commitdiff/960d7aa95fd85d333458d7fcada31d6575981c57 More detail: according to the gdb, in XS_Digest__SHA_hmac_sha1, the "cv" is NULL, but the "ix" pulled in by dereferencing the "cv"... See: http://www.nntp.perl.org/group/perl.perl5.porters/2014/06/msg216966.html If the 5.9x broke this, and there will be a fix, that'd be great, but in the meanwhile the workaround (dropping the optimization level) seems to work.
On Thu Jun 19 15:06:33 2014, JHI wrote: Show quoted text
> I ran into the same and I found a workaround, which I applied to the > Perl 5 git repo: > > http://perl5.git.perl.org/perl.git/commitdiff/960d7aa95fd85d333458d7fcada31d6575981c57 > > More detail: according to the gdb, in XS_Digest__SHA_hmac_sha1, the > "cv" is NULL, but the "ix" pulled in by dereferencing the "cv"... > > See: > http://www.nntp.perl.org/group/perl.perl5.porters/2014/06/msg216966.html > > If the 5.9x broke this, and there will be a fix, that'd be great, but > in the meanwhile the workaround (dropping the optimization level) > seems to work.
Quoting from the second link above ... Show quoted text
> But, ummm... let's go back to that stack trace.... yikes, cv is NULL. > So the ix is pulled out of the Abyss.
Show quoted text
> Sooo... crash caused by the optimizer, so that's partly to blame... but > why is the cv NULL to begin with? And why does this work elsewhere, and > without optimizer?
Why indeed. SHA.xs is doing nothing tricky, unusual or controversial with regard to the 'ix' variable (ref. perldoc perlxs, 'The ALIAS: Keyword'), so there's nothing to fix here in Digest::SHA.
I think "rejecting" this ticket is very wrong unless you can prove the bug is NOT in this module The test also dumps core with older perl versions (I tested 5.14.2 and blead) The test also dumps core with no optimizing at all (-O0) The test also dumps core with GNU gcc (I tested 4.6.1 and 4.7.2)
On Fri Oct 10 04:10:39 2014, HMBRAND wrote: Show quoted text
> I think "rejecting" this ticket is very wrong unless you can prove the > bug is NOT in this module > > The test also dumps core with older perl versions (I tested 5.14.2 and > blead) > > The test also dumps core with no optimizing at all (-O0) > > The test also dumps core with GNU gcc (I tested 4.6.1 and 4.7.2)
Jarkko did indeed prove that the bug is NOT in Digest::SHA. His analysis here http://www.nntp.perl.org/group/perl.perl5.porters/2014/06/msg216966.html shows that 'cv' is NULL on subroutine entry, causing 'ix' to have an arbitrary value. Expectedly this results in a core dump. The question is why cv is NULL in the first place? My code doesn't use the XSUB interface in a tricky or unusual way. And if there's a problem with xsubpp code generation, it's very odd that it hasn't surfaced until now. Mark
Jarkko recently points out that 'struct SHA' (src/sha.h) does indeed have problems: attempting to share the state information ('H') across 32-bit and 64-bit types by declaring it as a 'char *' can cause addressing exceptions when subsequently accessing 'H' as a 32-bit or 64-bit integer pointer. See Section A6.6 (Pointers and Integers) in Appendix A of K&R's 'The C Programming Language' for details about such possible addressing exceptions. The notion of alignment is implementation-dependent, so a stricter approach to typing is necessary for the SHA state information. The natural model for such information would be something like union STATE { SHA32 w32; SHA64 w64; } H[8]; but this is too disruptive to the structure of existing code. Therefore a slightly less space-efficient approach will be used, viz. SHA32 H32[8]; SHA64 H64[8]; which accommodates all alignment requirements with a minimum of code changes.
RT-Send-CC: jhi [...] iki.fi
Fixed in 5.93