Subject: Re: OS X Crash in libssh2_session_startup() - EXC_BAD_ACCESS (code=1 address=0x0)

Re: OS X Crash in libssh2_session_startup() - EXC_BAD_ACCESS (code=1 address=0x0)

From: Engstrom, John <john.engstrom_at_tditechnologies.com>
Date: Fri, 4 Sep 2015 08:21:21 -0500

Just wanted to give a quick note letting folks know I got to the bottom of what was going on. In my application I was not setting a compile macro to indicate that OpenSSL should be used therefore the call to OpenSSL_add_all_digests() was not getting called in my application before using libssh2. Once I added in the compile macro and OpenSSL got initialized then everything worked.

Sorry for the wild goose chase and thanks to all who replied.

John Engstrom

On Sep 1, 2015, at 10:27 AM, John Engstrom <john.engstrom_at_tditechnologies.com<mailto:john.engstrom_at_tditechnologies.com>> wrote:


On Sep 1, 2015, at 4:40 AM, Daniel Stenberg <daniel_at_haxx.se<mailto:daniel_at_haxx.se>> wrote:

On Mon, 31 Aug 2015, Engstrom, John wrote:

I have an application that is using libssh2 and when I call into
libssh2_session_startup() I’m crashing. The calling code looks like this:

The stack trace of the crash is:
#0 0x0000000000000000 in 0x00000000 ()
#1 0x0000000101354380 in diffie_hellman_sha1 ()
#2 0x0000000101356765 in kex_method_diffie_hellman_group14_sha1_key_exchange ()
#3 0x00000001013522bf in _libssh2_kex_exchange ()
#4 0x000000010135e2fe in session_startup ()
#5 0x000000010135e088 in libssh2_session_handshake ()
#6 0x000000010135e5db in libssh2_session_startup ()

Any suggestions on what might be going on or what I could do to diagnose it?

Run it with a debugger (after you build libssh2 debug-enabled) and check our
frame 1 and 2 where it went wrong and why?




Daniel,

I built libssh2 debug-enabled. Here is the results:

It’s crashing at line 249 of kex.c:
libssh2_sha1_update(fingerprint_ctx, session->server_hostkey,
                                session->server_hostkey_len);

Here’s my examination of the variables in use at that line:
(lldb) print fingerprint_ctx
(EVP_MD_CTX) $0 = {
  digest = 0x0000000000000000
  engine = 0x0000000000000000
  flags = 0
  md_data = 0x0000000000000000
  pctx = 0x0000000000000000
  update = 0x0000000000000000
}
(lldb) print session->server_hostkey
(unsigned char *) $1 = 0x0000000108d7a460 ""
(lldb) print session->server_hostkey_len
(uint32_t) $2 = 149
(lldb)


Here’s the examination of memory at 0x108d7a460

00 00 00 07 73 73 68 2D 72 73 61 00 00 00 01 23 00 00 00 81 00 A2 EE A4 89 2B 5F 57 D5 D8 30 3A 22 4B D1
9B 00 24 76 32 5E 67 9A 8D 1B 2C F6 8C 13 72 66 F7 A5 33 DE 35 BD C5 1C 77 D3 10 6F 48 2E F2 72 53 F6 E9
D4 72 5C AB 93 6D DE 5D 07 BE 15 1A 59 47 24 0A 88 6F 9E FF 61 3D 16 46 66 1E 3A 6F D2 BA B8 DD 07 2A AD
A7 03 94 4E 67 12 63 82 84 5E A0 2F 66 AA D8 80 AC 10 18 1E D2 17 6C 2F 3C C0 11 4B 5B 7A 6E 09 1E E2 12
07 FC E9 6A 9C 2A F8 53 0D 00 00 00 FD 7A 8D 10 00 00 00 F0 FA 9B 8D 10 00 00 00 10 93 7A 8D 10 00 00 00
90 34 31 43 37 30 36 41 39 38 39 38 36 46 00 00 00 34 31 43 37 30 36 41 39 38 39 38 36 46 00 00 00 43 6A
8D 10 00 00 00 30 F9 98 8D 10 00 00 00 10 03 00 6F 6D 70 5F 6B 65 79 00 00 09 01 00 00 00 68 5B 1F 0D 01
00 00 00 42 70 8D 10 00 00 03 00 40 9C D6 08 01 00 00 00 F0 A5 D7 08 01 00 00 00 01 01 00 00 00 00 00 00
20 A5 D7 08 01 00 00 00 00 00 00 00 00 00 00 00 2E A5 D7 08 01 00 00 00 20 A5 D7 08 01 00 00 00 00 00 00
00 00 00 00 00 34 31 43 37 30 36 41 39 38 39 38 36 45 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 FF 00 00 00 00 00 00 C0 A2 D6 08 01 00 00 00 00 00 00 00 00 00 00 00 CE A2 D6 08 01 00 00 00 C0
A2 D6 08 01 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 D0 11 D7 08 01 00 00 00 01 01 00 00
00 00 00 00 F0 9B D6 08 01 00 00 00 00 00 00 00 00 00 00 00 FE 9B D6 08 01 00 00 00 F0 9B D6 08 01 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 6D 64 5F 69 6E 5F 71 00 00 00 00 00 00 00 00 00

_______________________________________________
libssh2-devel http://cool.haxx.se/cgi-bin/mailman/listinfo/libssh2-devel
Received on 2015-09-04