Operating System - HP-UX
1748072 Members
5622 Online
108758 Solutions
New Discussion юеВ

64bit Binary crashes on HP-UX 11.31IA

 
chenn_1
Advisor

64bit Binary crashes on HP-UX 11.31IA

Greetings!

I am currently met a problem during compiling 64bit openssl fips binary on HPUX11v3IA platform.

There're two 11.31IA machines. I used the same source code and make file on both of them, and then build openssl fips binary individually.

The built binary on machine A works OK, while the binary on machine B throws out SIGSEGV. I use gdb and found that binary A and B run in different workflows. For binary B, I even can not break at a "main" function.

Both of the two machines use the same version of HP develper's bundle. That is as below.
B9007AA C.11.31.04.2 HP C/aC++ Developer's Bundle

Does this problem due to system configuration? Because I thought the compilers are the same. Or this is caused by some other reason.
Thanks in advance.

Here's the gdb log of binary A (the OK one):

root@sshpa6# gdb ./openssl
Detected 64-bit executable.
Invoking /opt/langtools/bin/gdb64.
HP gdb 5.9 for PA-RISC 2.0 (wide), HP-UX 11.00
and target hppa2.0w-hp-hpux11.00.
Copyright 1986 - 2001 Free Software Foundation, Inc.
Hewlett-Packard Wildebeest 5.9 (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.
..
warning:
In object file "/home/adam/temp2/Build-SSL-97m98o-001/openssl/openssl-fips-0.9.7j-dev/apps/./openssl":


warning: File "fips_rand_selftest.c" [0x90] crosses beginning of module "fips_dsa_ossl.c".

warning: Module "fips_dsa_ossl.c" [0x8a] has ending address after starting address of next module; adjusting ending address down.

warning: Module "fips_set_key.c" [0x8b] has ending address after starting address of next module; adjusting ending address down.

warning: Module "fips_des_selftest.c" [0x8c] has ending address after starting address of next module; adjusting ending address down.

warning: Module "fips_rand.c" [0x8d] has ending address after starting address of next module; adjusting ending address down.

warning: Found procedure "DES_encrypt1" [0x441] that is not in any file or module.

warning: Found procedure "FIPS_selftest_des" [1093] that is not in any file or module.

warning: Found procedure "FIPS_dsa_check" [1106] that is not in any file or module.

(gdb) b m_sha1.c:75
Breakpoint 1 at 0x40000000000c7d54: file m_sha1.c, line 75 from /home/adam/temp2/Build-SSL-97m98o-001/openssl/openssl-fips-0.9.7j-dev/apps/./openssl.
(gdb) r sha1 *
Starting program: /home/adam/temp2/Build-SSL-97m98o-001/openssl/openssl-fips-0.9.7j-dev/apps/./openssl sha1 *

Breakpoint 1, update (ctx=0x8000000100043e80, data=0x8000000100048970, count=6131) at m_sha1.c:75
75 return SHA1_Update(ctx->md_data,data,count);
(gdb) s
SHA1_Update (c=0x8000000100043f30, data_=0x8000000100048970, len=6131) at fips_md32_common.h:398
398 const unsigned char *data=data_;
(gdb) bt
#0 SHA1_Update (c=0x8000000100043f30, data_=0x8000000100048970, len=6131) at fips_md32_common.h:398
#1 0x40000000000c7d6c in update (ctx=0x8000000100043e80, data=0x8000000100048970, count=6131) at m_sha1.c:75
#2 0x40000000000c3340 in EVP_DigestUpdate (ctx=0x8000000100043e80, data=0x8000000100048970, count=6131) at digest.c:258
#3 0x40000000001dbff4 in md_read (b=0x8000000100043e00,
out=0x8000000100048970 "$! CA - wrapper around ca to make it easier to use ... basically ca requires\n$! some setup stuff to be done before you can use it and this makes\n$! things easier between now and when Eric is"..., outl=8192) at bio_md.c:133
#4 0x400000000009aa10 in BIO_read (b=0x8000000100043e00, out=0x8000000100048970, outl=8192) at bio_lib.c:166
#5 0x4000000000122eb4 in do_fp (out=0x8000000100043eb0,
buf=0x8000000100048970 "$! CA - wrapper around ca to make it easier to use ... basically ca requires\n$! some setup stuff to be done before you can use it and this makes\n$! things easier between now and when Eric is"..., bp=0x8000000100043e00, sep=0, binout=0, key=0x0, sigin=0x0, siglen=0, title=0x8000000100043fa8 "SHA1(CA.com)= ", file=0x800003ffefff005a "CA.com",
bmd=0x8000000100043e00, hmac_key=0x0, non_fips_allow=0) at dgst.c:444
#6 0x4000000000122bc4 in dgst_main (argc=137, argv=0x800003ffefff0f38) at dgst.c:395
#7 0x4000000000118cb0 in do_cmd (prog=0x8000000100042b38, argc=138, argv=0x800003ffefff0f30) at openssl.c:395
#8 0x400000000011877c in main (Argc=138, Argv=0x800003ffefff0f30) at openssl.c:314



Here's the gdb log of binary B ( the SIGSEGV one)

root@sshpa5# gdb ./openssl
Detected 64-bit executable.
Invoking /opt/langtools/bin/gdb64.
HP gdb 5.9 for PA-RISC 2.0 (wide), HP-UX 11.00
and target hppa2.0w-hp-hpux11.00.
Copyright 1986 - 2001 Free Software Foundation, Inc.
Hewlett-Packard Wildebeest 5.9 (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.
..
(gdb) b main
Breakpoint 1 at 0x4000000000119890: file openssl.c, line 226 from /home/adam/temp3/Build-SSL-97m98o-001/openssl/openssl-fips-0.9.7j-dev/apps/./openssl.
(gdb) r
Starting program: /home/adam/temp3/Build-SSL-97m98o-001/openssl/openssl-fips-0.9.7j-dev/apps/./openssl

Program received signal SIGSEGV, Segmentation fault
si_code: 0 - SEGV_UNKNOWN - Unknown Error.
0x40000000000afd28 in sha1_block_host_order (c=0x800000010002d120, d=0x4000000000119238, num=67077490) at fips_sha_locl.h:252
252 fips_sha_locl.h: No such file or directory.
in fips_sha_locl.h
(gdb) bt
#0 0x40000000000afd28 in sha1_block_host_order (c=0x800000010002d120, d=0x4000000000119238, num=67077490) at fips_sha_locl.h:252
#1 0x40000000000b4794 in SHA1_Update (c=0x800000010002d120, data_=0x4000000000119238, len=4294384200) at fips_md32_common.h:473
#2 0x40000000000dae34 in update (ctx=0x800003ffefff12a8, data=0x4000000000119238, count=4294384200) at m_sha1.c:75
#3 0x40000000000df658 in EVP_DigestUpdate (ctx=0x800003ffefff12a8, data=0x4000000000119238, count=4294384200) at digest.c:258
#4 0x40000000000a1574 in HMAC_Update (ctx=0x800003ffefff12a0, data=0x4000000000119238 "\b", len=-583096) at fips_hmac.c:134
#5 0x4000000000118d64 in FIPS_incore_fingerprint (sig=0x800003ffefff11b8 "", len=20) at fips.c:171
#6 0x40000000001193cc in FINGERPRINT_premain () at ../fips-1.0/../fips-1.0/fips_premain.c:100
#7 0xc00000000000d668 in IN_do_list+0x150 () from /usr/lib/pa20_64/dld.sl
#8 0xc00000000001b3a0 in crt_dld_main+0xa08 () from /usr/lib/pa20_64/dld.sl
#9 0xc00000000000b8d8 in $START$+0x80 () from /usr/lib/pa20_64/dld.sl
Error accessing memory address 0x0: Invalid argument.
8 REPLIES 8
chenn_1
Advisor

Re: 64bit Binary crashes on HP-UX 11.31IA

We can see that the normal workflow is main->do_cmd->dgst_main->do_fp->...

Meanwhile, the failed workflow is $START$->crt_dld_main->IN_do_list->FRINGERPRINT_premain->...

Seems that the second binary depends on some dynamicl linked libraries.
Considering that the Makefiles on both machines are the same. What causes this difference?

Openssl.c related line in Makefile is:
cc -DMONOLITH -I.. -I../include -DOPENSSL_THREADS -D_REENTRANT -DOPENSSL_NO_KRB5 -Ae -g +DD64 +O3 +ESlit -z -DB_ENDIAN -DMD32_XARRAY -c -o openssl.o openssl.c
chenn_1
Advisor

Re: 64bit Binary crashes on HP-UX 11.31IA

And this one, we got the openssl binary.

+ ../fips-1.0/fipsld -o openssl -DMONOLITH -I.. -I../include -DOPENSSL_THREADS -D_REENTRANT -DOPENSSL_NO_KRB5 -Ae -g +DD64 +O3 +ESlit -z -DB_ENDIAN -DMD32_XARRAY openssl.o verify.o asn1pars.o req.o dgst.o dh.o dhparam.o enc.o passwd.o gendh.o errstr.o ca.o pkcs7.o crl2p7.o crl.o rsa.o rsautl.o dsa.o dsaparam.o x509.o genrsa.o gendsa.o s_server.o s_client.o speed.o s_time.o apps.o s_cb.o s_socket.o app_rand.o version.o sess_id.o ciphers.o nseq.o pkcs12.o pkcs8.o spkac.o smime.o rand.o engine.o ocsp.o prime.o ../libssl.a ../libcrypto.a -Wl,+s,+b,/opt/openssl/lib -ldl
Dennis Handly
Acclaimed Contributor

Re: 64bit Binary crashes on HP-UX 11.31IA

>They're two 11.31IA machines.

These look like PA executables.

>Both of the two machines use the same version of HP developer's bundle.

Do you have the same runtime patches on each?

For the one that works, do you get to sha1_block_host_order before main too?

>Seems that the second binary depends on some shared libraries.

The second one is dying doing static construction. Or pragma init.

>+O3

You might want to remove this so you can debug.
chenn_1
Advisor

Re: 64bit Binary crashes on HP-UX 11.31IA

>>They're two 11.31IA machines.

>These look like PA executables.

Yes, I made a mistake. These two machines are PA boxes.

>>Both of the two machines use the same version of HP developer's bundle.

>Do you have the same runtime patches on each?

Would you please tell me by what command I can check this?

>For the one that works, do you get to sha1_block_host_order before main too?

For the one works, I setup a break point at sha1_block_host_order. The call stack is as below:
#0 sha1_block_host_order
#1 SHA1_Update
#2 update
#3 EVP_DigestUpdate
#4 md_read
#5 BIO_read
#6 do_fp
#7 dgst_main
#8 do_cmd
#9 main

Looks like it works OK.

>>Seems that the second binary depends on some shared libraries.

>The second one is dying doing static construction. Or pragma init.

So, can we say that the second one at the beginning tried doing static construction, but failed. Why it failed?

>>+O3

>You might want to remove this so you can debug.

Thanks, I am trying this now.


For more, I consider if this problem is caused by different systems' header files. I've copied all the files in /usr/inlcude/ from one machine to another. Seems doesn't get any progress at all.
James R. Ferguson
Acclaimed Contributor

Re: 64bit Binary crashes on HP-UX 11.31IA

Hi:

> Do you have the same runtime patches on each?
>> Would you please tell me by what command I can check this?

You could compare ('diff') the output from both machines of:

# show_patches -a -s -l product

> I've copied all the files in /usr/inlcude/ from one machine to another.

This wasn't prudent. Any patches applied only to one machine and not the other that have delivered new header files are not correctly reflected in the IPD (Installed Product Database of '/var/adm/sw'). You might want to run:

# swverify \*

...which will take some time, but will expose potential areas of concern following this copy.

Regards!

...JRF...
Dennis Handly
Acclaimed Contributor

Re: 64bit Binary crashes on HP-UX 11.31IA

>make file on both of them, and then build openssl fips binary individually.

Why are you building it twice? Why not build it once and copy to both machines?

If it is a patch issue, copy the good executable to the machine where it fails. If the good now fails, it is the runtime.
chenn_1
Advisor

Re: 64bit Binary crashes on HP-UX 11.31IA

>>make file on both of them, and then build openssl fips binary individually.

>Why are you building it twice? Why not build it once and copy to both machines?

The build failed on the 1st machine. When I tried on the second one, it's strange that the same code package passed building. In this case, I am wondering if I could make it successful on the 1st one.

>If it is a patch issue, copy the good executable to the machine where it fails. If the good now fails, it is the runtime.

I copied the good executable to the machine where it fails, the binary works fine. On the other hand, I copied the bad excutable to the OK machine, it can not work neither.
Dennis Handly
Acclaimed Contributor

Re: 64bit Binary crashes on HP-UX 11.31IA

>I copied the good executable to the machine where it fails, the binary works fine. OI copied the bad executable to the OK machine, it can not work neither.

So it tracks what you built. Either some headers or included archive lib is difference between the two machines.