From libssh2-devel-bounces@cool.haxx.se  Fri Aug  9 04:44:48 2019
Return-Path: <libssh2-devel-bounces@cool.haxx.se>
Received: from www.haxx.se (mail [127.0.0.1])
	by giant.haxx.se (8.15.2/8.15.2/Debian-4) with ESMTP id x792i7IE011897;
	Fri, 9 Aug 2019 04:44:36 +0200
Received: from sonic309-20.consmr.mail.bf2.yahoo.com
 (sonic309-20.consmr.mail.bf2.yahoo.com [74.6.129.194])
 by giant.haxx.se (8.15.2/8.15.2/Debian-4) with ESMTPS id x792i2JK011750
 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128 verify=NOT)
 for <libssh2-devel@cool.haxx.se>; Fri, 9 Aug 2019 04:44:03 +0200
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=rogers.com; s=s2048;
 t=1565318637; bh=uMBuueIQdMi0WiqBLBO68cLV7AB+v4w/rZfDaPx1XYY=;
 h=Subject:To:References:From:Date:In-Reply-To:From:Subject;
 b=g0mDA1MnpyydoqpZ9AukbYdCcWAop1XLPZGU5CApBUkNSJPcAtXzN71ZfieRBTnKZTTHPVS51nqOZIz/6ik7g8mbm96Iu9SketuMkm9ywn7/QH3kDxWmalsxuBBuAmi7dMsE2v2qjoYJyO36M6CGlmewkXz1G9lPyNuLVdqoh2vdzZESLxUn5iZrWbVr7hcqcfgTnoB82cxDboOExiWbSQs8HtuJVyKg7qqd4krsmFTHUwq+5PjkntBj1/3Ylmp5ivxqV8mftha7U468F932CohQvkcd/+9JImHmKU3UYYtXDa5lQmzHkwZ3uS/izzYwkxAxUq5Nw65YI49t4vhT6w==
X-YMail-OSG: 5Wwb0dQVM1mT_XosVZAsn0aZEBGD3BrqdRFSDv.JDUTkuvY7QG4SC2vsiQUwqBZ
 osjPFV9IJpq7kNyAv1lKjHnwQgQsy6OmWfZSAj_4uTtV.Lc9QaGw2TagfZmn3rquET5Ngj1dRovu
 iLaG31csTNboXp9cNP6y6zx1HL_4Xc5r5XL1IQqSa3m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YQEKuqQRI55mzCgLU.i5bknUdpx6URC1O55vyS27k3Dva
 KbQIBii3L7dER434QWskt
Received: from sonic.gate.mail.ne1.yahoo.com by
 sonic309.consmr.mail.bf2.yahoo.com with HTTP; Fri, 9 Aug 2019 02:43:57 +0000
Received: by smtp420.mail.bf1.yahoo.com (Oath Hermes SMTP Server) with ESMTPA
 ID 15f291c7302d07f2eb167d46ff6f7270; 
 Fri, 09 Aug 2019 02:43:52 +0000 (UTC)
Subject: Re: libssh crash on Mac
To: libssh2 development <libssh2-devel@cool.haxx.se>
References: <06f444aa-383a-8431-9da0-0f1f8cd51e07@rogers.com>
 <20190307112528.18089.qmail@stuge.se>
 <34d20f30-473f-c317-d5f3-cce8bf3f7c60@rogers.com>
 <0e7652e3-59f2-6864-dc5a-530e686ad40b@rogers.com>
 <20190504225817.8009.qmail@stuge.se>
From: Leo <leo.r@rogers.com>
Message-ID: <a4f3646f-0edb-59b4-b20c-410515e94170@rogers.com>
Date: Thu, 8 Aug 2019 22:43:51 -0400
User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.14; rv:60.0)
 Gecko/20100101 Thunderbird/60.8.0
MIME-Version: 1.0
In-Reply-To: <20190504225817.8009.qmail@stuge.se>
Content-Language: en-US
X-BeenThere: libssh2-devel@cool.haxx.se
X-Mailman-Version: 2.1.22
Precedence: list
List-Id: libssh2 development <libssh2-devel.cool.haxx.se>
List-Unsubscribe: <https://cool.haxx.se/cgi-bin/mailman/options/libssh2-devel>, 
 <mailto:libssh2-devel-request@cool.haxx.se?subject=unsubscribe>
List-Archive: <http://cool.haxx.se/pipermail/libssh2-devel/>
List-Post: <mailto:libssh2-devel@cool.haxx.se>
List-Help: <mailto:libssh2-devel-request@cool.haxx.se?subject=help>
List-Subscribe: <https://cool.haxx.se/cgi-bin/mailman/listinfo/libssh2-devel>, 
 <mailto:libssh2-devel-request@cool.haxx.se?subject=subscribe>
Reply-To: libssh2 development <libssh2-devel@cool.haxx.se>
Content-Type: text/plain; charset="utf-8"; Format="flowed"
Errors-To: libssh2-devel-bounces@cool.haxx.se
Sender: "libssh2-devel" <libssh2-devel-bounces@cool.haxx.se>
Content-Transfer-Encoding: 8bit
X-MIME-Autoconverted: from base64 to 8bit by giant.haxx.se id x792i7IE011897

On 5/4/19 6:58 PM, Peter Stuge wrote:
> Leo wrote:
>> I finally was able to compile the Xcode app with libssh2 1.8.0 using
>> libssh2.a library.
> That's good progress. Please build libssh2 with debug
> (--enable-debug if using ./configure) and then add this line:
>
> libssh2_trace(session, ~0);
>
> after the call to libssh2_session_init() but before the call to
> libssh2_session_handshake().

Hi Peter,

I finally can get back to this issue after spending lengthy time on 
implementing Apple's notarization in my apps.


I followed your instructions and built libssh2 with --enable-debug.

Now when I try to connect to SFTP site, the crash produces the following 
output in Xcode debugger:

openssl.c > _libssh2_openssl_crypto_init()


#if OPENSSL_VERSION_NUMBER >= 0x10100000L && \
 ?????? !defined(LIBRESSL_VERSION_NUMBER)
 ?????? #ifndef OPENSSL_NO_ENGINE
 ?????????????? ENGINE_load_builtin_engines();?????????????????????????????????? <-- Thread 8: 
EXC_BAD_ACCESS (code=1, address=0x116)
 ?????????????? ENGINE_register_all_complete();
 ?????? #endif


As you suggested, I also inserted libssh2_trace(session, ~0); after the 
call to libssh2_session_init() but before the call to 
libssh2_session_handshake() - but the crash happens before getting to 
that line.


Does the error above make any sense?


Thanks,
Leo
_______________________________________________
libssh2-devel https://cool.haxx.se/cgi-bin/mailman/listinfo/libssh2-devel

From libssh2-devel-bounces@cool.haxx.se  Fri Aug  9 05:24:39 2019
Return-Path: <libssh2-devel-bounces@cool.haxx.se>
Received: from www.haxx.se (mail [127.0.0.1])
	by giant.haxx.se (8.15.2/8.15.2/Debian-4) with ESMTP id x793OFv5001122;
	Fri, 9 Aug 2019 05:24:30 +0200
Received: from blaine.gmane.org (195-159-176-226.customer.powertech.no
 [195.159.176.226])
 by giant.haxx.se (8.15.2/8.15.2/Debian-4) with ESMTPS id x793ODVq001077
 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT)
 for <libssh2-devel@cool.haxx.se>; Fri, 9 Aug 2019 05:24:13 +0200
Received: from list by blaine.gmane.org with local (Exim 4.89)
 (envelope-from <gnslg-libssh2-devel-2@m.gmane.org>)
 id 1hvvVm-000YIU-42
 for libssh2-devel@cool.haxx.se; Fri, 09 Aug 2019 05:24:14 +0200
X-Injected-Via-Gmane: http://gmane.org/
To: libssh2-devel@cool.haxx.se
From: Jan Ehrhardt <phpdev@ehrhardt.nl>
Subject: Re: libssh crash on Mac
Date: Fri, 09 Aug 2019 05:24:01 +0200
Message-ID: <efppkedcf1pj1khq8padeied76lhr9814u@4ax.com>
References: <06f444aa-383a-8431-9da0-0f1f8cd51e07@rogers.com>
 <20190307112528.18089.qmail@stuge.se>
 <34d20f30-473f-c317-d5f3-cce8bf3f7c60@rogers.com>
 <0e7652e3-59f2-6864-dc5a-530e686ad40b@rogers.com>
 <20190504225817.8009.qmail@stuge.se>
 <20190504225817.8009.qmail-Y+HMSxxDrH8@public.gmane.org>
 <a4f3646f-0edb-59b4-b20c-410515e94170@rogers.com>
Mime-Version: 1.0
X-Newsreader: Forte Agent 3.3/32.846
X-BeenThere: libssh2-devel@cool.haxx.se
X-Mailman-Version: 2.1.22
Precedence: list
List-Id: libssh2 development <libssh2-devel.cool.haxx.se>
List-Unsubscribe: <https://cool.haxx.se/cgi-bin/mailman/options/libssh2-devel>, 
 <mailto:libssh2-devel-request@cool.haxx.se?subject=unsubscribe>
List-Archive: <http://cool.haxx.se/pipermail/libssh2-devel/>
List-Post: <mailto:libssh2-devel@cool.haxx.se>
List-Help: <mailto:libssh2-devel-request@cool.haxx.se?subject=help>
List-Subscribe: <https://cool.haxx.se/cgi-bin/mailman/listinfo/libssh2-devel>, 
 <mailto:libssh2-devel-request@cool.haxx.se?subject=subscribe>
Reply-To: libssh2 development <libssh2-devel@cool.haxx.se>
Content-Type: text/plain; charset="utf-8"
Errors-To: libssh2-devel-bounces@cool.haxx.se
Sender: "libssh2-devel" <libssh2-devel-bounces@cool.haxx.se>
Content-Transfer-Encoding: 8bit
X-MIME-Autoconverted: from base64 to 8bit by giant.haxx.se id x793OFv5001122

Leo in gmane.network.ssh.libssh2.devel (Thu, 8 Aug 2019 22:43:51 -0400):
>On 5/4/19 6:58 PM, Peter Stuge wrote:
>> Leo wrote:
>>> I finally was able to compile the Xcode app with libssh2 1.8.0 using
>>> libssh2.a library.
>> That's good progress. Please build libssh2 with debug
>> (--enable-debug if using ./configure) and then add this line:
>>
>> libssh2_trace(session, ~0);
>>
>> after the call to libssh2_session_init() but before the call to
>> libssh2_session_handshake().
>
>Hi Peter,
>
>I finally can get back to this issue after spending lengthy time on 
>implementing Apple's notarization in my apps.
>
>I followed your instructions and built libssh2 with --enable-debug.
>
>Now when I try to connect to SFTP site, the crash produces the following 
>output in Xcode debugger:
>
>openssl.c > _libssh2_openssl_crypto_init()
>
>
>#if OPENSSL_VERSION_NUMBER >= 0x10100000L && \
> ?????? !defined(LIBRESSL_VERSION_NUMBER)
> ?????? #ifndef OPENSSL_NO_ENGINE
> ?????????????? ENGINE_load_builtin_engines();?????????????????????????????????? <-- Thread 8: 
>EXC_BAD_ACCESS (code=1, address=0x116)
> ?????????????? ENGINE_register_all_complete();
> ?????? #endif

libssh2 version 1.8.0 needs a patch to compile with OpenSSL 1.1.1. See
https://github.com/Frugghi/iSSH2/issues/7
and the patch in
https://github.com/Jan-E/iSSH2/commit/6b2b61d56fc43642980aacc529c9d9d14263cebf#diff-47bf3a78aa165576c6c85a942ddf572bR6

You'd better upgradeto libssh2 1.9.0. It compiles fine in Xcode.
https://github.com/Frugghi/iSSH2 will create the necessary binaries for
Xcode.
-- 
Jan

_______________________________________________
libssh2-devel https://cool.haxx.se/cgi-bin/mailman/listinfo/libssh2-devel

From libssh2-devel-bounces@cool.haxx.se  Sat Aug 10 04:35:54 2019
Return-Path: <libssh2-devel-bounces@cool.haxx.se>
Received: from www.haxx.se (mail [127.0.0.1])
	by giant.haxx.se (8.15.2/8.15.2/Debian-4) with ESMTP id x7A2ZBpX016173;
	Sat, 10 Aug 2019 04:35:45 +0200
Received: from sonic314-24.consmr.mail.gq1.yahoo.com
 (sonic314-24.consmr.mail.gq1.yahoo.com [98.137.69.87])
 by giant.haxx.se (8.15.2/8.15.2/Debian-4) with ESMTPS id x7A2Z876015943
 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128 verify=NOT)
 for <libssh2-devel@cool.haxx.se>; Sat, 10 Aug 2019 04:35:09 +0200
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=rogers.com; s=s2048;
 t=1565404503; bh=AGAtSCNmfGnt5dCaxOhniYjcQm+U8yufv1Kn9DFjwsM=;
 h=From:Subject:To:References:Date:In-Reply-To:From:Subject;
 b=a9bCHgaEqutN2BbFls3JQikr1QF4vnxlXc2VqxOycJ7HHeGH3tFjMzXGIWOX49xe7NOnJuASnp+Rg6TtGA6CpJgm+FsQo/a01qQDf9FGbG5IjHc4bg60LqvsJ7f8Ks63tCA0A2Z5HjOubKexRBday502sQV/65ksXU2MtfqsEtaSmFb+JilkdaV77ETYIcA0+eOWHp3fF0bU7xCgmK4qasndxzcg3G1Z5fXGy+Huci39i7Gpz84dcttUW4RIrHbpcwmsPf1+uUojcAGRi4dMHu5kwYuDuXSAPXxA+O8KWfHw2G+/JZXLspAiDs/VZAX1f848yee96LKNReT1Yiz6+A==
X-YMail-OSG: t8CvbrIVM1kwh2pkfTgPVVO9aRbGC1uwhndi3kK_N55Yv2stNfIM1vYLAeSOqMx
 FvJ_Kwgm.PEz4llbpoUPlC7fIcWqaDAMgJFfaUFILa4vJkgxBlCbfVbzjW22M_8mvjwsba5FoVj_
 4ISiJgIhvwOtmvgjCb5TUkTo9PS7IfvCCfBXWp4fBXWLSEU3wvoIS77DyEqMdO02Mxax1MQGg4_V
 76AaLTdhlSNyT3ydhwXv99JI_ZxeBE6HneNqHTyX4BjYtVCpf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UkqmonUF_s1L01o7iBNl
Received: from sonic.gate.mail.ne1.yahoo.com by
 sonic314.consmr.mail.gq1.yahoo.com with HTTP; Sat, 10 Aug 2019 02:35:03 +0000
Received: by smtp408.mail.gq1.yahoo.com (Oath Hermes SMTP Server) with ESMTPA
 ID fe82318f2042301534ea52a98d8748f1; 
 Sat, 10 Aug 2019 02:35:01 +0000 (UTC)
From: Leo <leo.r@rogers.com>
Subject: Re: libssh crash on Mac
To: libssh2 development <libssh2-devel@cool.haxx.se>
References: <06f444aa-383a-8431-9da0-0f1f8cd51e07@rogers.com>
 <20190307112528.18089.qmail@stuge.se>
 <34d20f30-473f-c317-d5f3-cce8bf3f7c60@rogers.com>
 <0e7652e3-59f2-6864-dc5a-530e686ad40b@rogers.com>
 <20190504225817.8009.qmail@stuge.se>
 <20190504225817.8009.qmail-Y+HMSxxDrH8@public.gmane.org>
 <a4f3646f-0edb-59b4-b20c-410515e94170@rogers.com>
 <efppkedcf1pj1khq8padeied76lhr9814u@4ax.com>
Message-ID: <dbf3c21a-2809-c6ff-f8e3-7fffe3869514@rogers.com>
Date: Fri, 9 Aug 2019 22:34:59 -0400
User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.14; rv:60.0)
 Gecko/20100101 Thunderbird/60.8.0
MIME-Version: 1.0
In-Reply-To: <efppkedcf1pj1khq8padeied76lhr9814u@4ax.com>
Content-Language: en-US
X-BeenThere: libssh2-devel@cool.haxx.se
X-Mailman-Version: 2.1.22
Precedence: list
List-Id: libssh2 development <libssh2-devel.cool.haxx.se>
List-Unsubscribe: <https://cool.haxx.se/cgi-bin/mailman/options/libssh2-devel>, 
 <mailto:libssh2-devel-request@cool.haxx.se?subject=unsubscribe>
List-Archive: <http://cool.haxx.se/pipermail/libssh2-devel/>
List-Post: <mailto:libssh2-devel@cool.haxx.se>
List-Help: <mailto:libssh2-devel-request@cool.haxx.se?subject=help>
List-Subscribe: <https://cool.haxx.se/cgi-bin/mailman/listinfo/libssh2-devel>, 
 <mailto:libssh2-devel-request@cool.haxx.se?subject=subscribe>
Reply-To: libssh2 development <libssh2-devel@cool.haxx.se>
Content-Type: text/plain; charset="utf-8"; Format="flowed"
Errors-To: libssh2-devel-bounces@cool.haxx.se
Sender: "libssh2-devel" <libssh2-devel-bounces@cool.haxx.se>
Content-Transfer-Encoding: 8bit
X-MIME-Autoconverted: from base64 to 8bit by giant.haxx.se id x7A2ZBpX016173

On 8/8/19 11:24 PM, Jan Ehrhardt wrote:
> Leo in gmane.network.ssh.libssh2.devel (Thu, 8 Aug 2019 22:43:51 -0400):
>> Now when I try to connect to SFTP site, the crash produces the following
>> output in Xcode debugger:
>>
>> openssl.c > _libssh2_openssl_crypto_init()
>>
>>
>> #if OPENSSL_VERSION_NUMBER >= 0x10100000L && \
>>   !defined(LIBRESSL_VERSION_NUMBER)
>>   #ifndef OPENSSL_NO_ENGINE
>>   ENGINE_load_builtin_engines();                                   <-- Thread 8: EXC_BAD_ACCESS (code=1, address=0x116)
>> ENGINE_register_all_complete();
>> #endif
> libssh2 version 1.8.0 needs a patch to compile with OpenSSL 1.1.1. See
> https://github.com/Frugghi/iSSH2/issues/7
> and the patch in
> https://github.com/Jan-E/iSSH2/commit/6b2b61d56fc43642980aacc529c9d9d14263cebf#diff-47bf3a78aa165576c6c85a942ddf572bR6
>
> You'd better upgradeto libssh2 1.9.0. It compiles fine in Xcode.
> https://github.com/Frugghi/iSSH2  will create the necessary binaries for
> Xcode.

Thanks Jan,

Here's more info regarding the issue and my configurations:

-I did build the latest version, libssh2 1.9.0

-I have no problem compiling my app in Xcode using libssh2.a; the app 
crashes on attempt to connect to any SFTP server.

-The app that crashes is quite a complex app that connects to various 
type of servers and does tons of other stuff. It worked with no issues 
for years. SFTP crashes started, apparently, after one of updates quite 
some time ago by now. By this time I have no way to know which update 
caused it (if that was the case at all).

On the other hand, I also have a simple app for my internal needs, which 
keeps working with libssh2 with no issues. This app, whose only task is 
to connect to SFTP, is a subset of the aforementioned large app. And 
when it comes to SFTP connection, both apps are pretty much identical. 
While trying to isolate the issue, I made those apps even more identical 
making sure that every line of Cocoa code that leads to SFTP is the same.

And yet one app crashes - and another doesn't.

There are no errors, exceptions or anything like this on the Cocoa part 
of code. Cocoa errors I'd be able to investigate further.

But the crash happens when the operation is passed to libssh2. So my 
only hope that someone here will be able to decipher the errors I see in 
Xcode debugger.


Cheers,
Leo


_______________________________________________
libssh2-devel https://cool.haxx.se/cgi-bin/mailman/listinfo/libssh2-devel

From libssh2-devel-bounces@cool.haxx.se  Mon Aug 12 00:48:49 2019
Return-Path: <libssh2-devel-bounces@cool.haxx.se>
Received: from www.haxx.se (mail [127.0.0.1])
	by giant.haxx.se (8.15.2/8.15.2/Debian-4) with ESMTP id x7BMmDCa001214;
	Mon, 12 Aug 2019 00:48:39 +0200
Received: from foo.stuge.se (foo.stuge.se [212.116.89.98])
 by giant.haxx.se (8.15.2/8.15.2/Debian-4) with ESMTPS id x7BMmBqO001201
 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT)
 for <libssh2-devel@cool.haxx.se>; Mon, 12 Aug 2019 00:48:11 +0200
Received: (qmail 30304 invoked by uid 1000); 11 Aug 2019 22:48:07 -0000
Message-ID: <20190811224807.30303.qmail@stuge.se>
Date: Sun, 11 Aug 2019 22:48:07 +0000
From: Peter Stuge <peter@stuge.se>
To: libssh2-devel@cool.haxx.se
Subject: Re: libssh crash on Mac
References: <06f444aa-383a-8431-9da0-0f1f8cd51e07@rogers.com>
 <20190307112528.18089.qmail@stuge.se>
 <34d20f30-473f-c317-d5f3-cce8bf3f7c60@rogers.com>
 <0e7652e3-59f2-6864-dc5a-530e686ad40b@rogers.com>
 <20190504225817.8009.qmail@stuge.se>
 <a4f3646f-0edb-59b4-b20c-410515e94170@rogers.com>
MIME-Version: 1.0
Content-Disposition: inline
In-Reply-To: <a4f3646f-0edb-59b4-b20c-410515e94170@rogers.com>
X-BeenThere: libssh2-devel@cool.haxx.se
X-Mailman-Version: 2.1.22
Precedence: list
List-Id: libssh2 development <libssh2-devel.cool.haxx.se>
List-Unsubscribe: <https://cool.haxx.se/cgi-bin/mailman/options/libssh2-devel>, 
 <mailto:libssh2-devel-request@cool.haxx.se?subject=unsubscribe>
List-Archive: <http://cool.haxx.se/pipermail/libssh2-devel/>
List-Post: <mailto:libssh2-devel@cool.haxx.se>
List-Help: <mailto:libssh2-devel-request@cool.haxx.se?subject=help>
List-Subscribe: <https://cool.haxx.se/cgi-bin/mailman/listinfo/libssh2-devel>, 
 <mailto:libssh2-devel-request@cool.haxx.se?subject=subscribe>
Reply-To: libssh2 development <libssh2-devel@cool.haxx.se>
Content-Type: text/plain; charset="utf-8"
Errors-To: libssh2-devel-bounces@cool.haxx.se
Sender: "libssh2-devel" <libssh2-devel-bounces@cool.haxx.se>
Content-Transfer-Encoding: 8bit
X-MIME-Autoconverted: from base64 to 8bit by giant.haxx.se id x7BMmDCa001214

Hi Leo,

Leo wrote:
> Now when I try to connect to SFTP site, the crash produces the following 
> output in Xcode debugger:
> 
> openssl.c > _libssh2_openssl_crypto_init()
> 
> 
> #if OPENSSL_VERSION_NUMBER >= 0x10100000L && \
>  ?????? !defined(LIBRESSL_VERSION_NUMBER)
>  ?????? #ifndef OPENSSL_NO_ENGINE
>  ?????????????? ENGINE_load_builtin_engines();?????????????????????????????????? <-- Thread 8: 
> EXC_BAD_ACCESS (code=1, address=0x116)
>  ?????????????? ENGINE_register_all_complete();
>  ?????? #endif
> 
> 
> As you suggested, I also inserted libssh2_trace(session, ~0); after the 
> call to libssh2_session_init() but before the call to 
> libssh2_session_handshake() - but the crash happens before getting to 
> that line.

That's good information.

It seems like you have no explicit call to libssh2_init() at startup
of your application, since you write that the crash happens when
trying to *connect* to an SFTP server.

I guess that you either have a call to libssh2_init() in a
constructor related to SFTP, that's not so good, because the library
should only be initialized a single time in a single thread for each
process.

I guess that OpenSSL was somehow already initialized, and the crash
happens becuse OpenSSL does not support being initialized twice.

If this is the case, please move or add the libssh2_init() call into your
application startup, immediately on startup, before any user interaction.

Then only call libssh2_session_init() in your SFTP constructor.

Let me know how it goes.


//Peter
_______________________________________________
libssh2-devel https://cool.haxx.se/cgi-bin/mailman/listinfo/libssh2-devel

From libssh2-devel-bounces@cool.haxx.se  Tue Aug 13 09:38:31 2019
Return-Path: <libssh2-devel-bounces@cool.haxx.se>
Received: from www.haxx.se (mail [127.0.0.1])
	by giant.haxx.se (8.15.2/8.15.2/Debian-4) with ESMTP id x7D7bqCT018950;
	Tue, 13 Aug 2019 09:38:22 +0200
Received: from blaine.gmane.org (195-159-176-226.customer.powertech.no
 [195.159.176.226])
 by giant.haxx.se (8.15.2/8.15.2/Debian-4) with ESMTPS id x7D7bo7Y018933
 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT)
 for <libssh2-devel@cool.haxx.se>; Tue, 13 Aug 2019 09:37:51 +0200
Received: from list by blaine.gmane.org with local (Exim 4.89)
 (envelope-from <gnslg-libssh2-devel-2@m.gmane.org>)
 id 1hxRNN-000mgs-Fe
 for libssh2-devel@cool.haxx.se; Tue, 13 Aug 2019 09:37:49 +0200
X-Injected-Via-Gmane: http://gmane.org/
To: libssh2-devel@cool.haxx.se
From: Jan Ehrhardt <phpdev@ehrhardt.nl>
Subject: Re: libssh crash on Mac
Date: Tue, 13 Aug 2019 09:37:40 +0200
Message-ID: <6gp4lepeo80e1mde9o2cvhiknr911pn9kj@4ax.com>
References: <20190307112528.18089.qmail@stuge.se>
 <34d20f30-473f-c317-d5f3-cce8bf3f7c60@rogers.com>
 <0e7652e3-59f2-6864-dc5a-530e686ad40b@rogers.com>
 <20190504225817.8009.qmail@stuge.se>
 <20190504225817.8009.qmail-Y+HMSxxDrH8@public.gmane.org>
 <a4f3646f-0edb-59b4-b20c-410515e94170@rogers.com>
 <efppkedcf1pj1khq8padeied76lhr9814u@4ax.com>
 <efppkedcf1pj1khq8padeied76lhr9814u-e09XROE/p8c@public.gmane.org>
 <dbf3c21a-2809-c6ff-f8e3-7fffe3869514@rogers.com>
Mime-Version: 1.0
X-Newsreader: Forte Agent 3.3/32.846
X-BeenThere: libssh2-devel@cool.haxx.se
X-Mailman-Version: 2.1.22
Precedence: list
List-Id: libssh2 development <libssh2-devel.cool.haxx.se>
List-Unsubscribe: <https://cool.haxx.se/cgi-bin/mailman/options/libssh2-devel>, 
 <mailto:libssh2-devel-request@cool.haxx.se?subject=unsubscribe>
List-Archive: <http://cool.haxx.se/pipermail/libssh2-devel/>
List-Post: <mailto:libssh2-devel@cool.haxx.se>
List-Help: <mailto:libssh2-devel-request@cool.haxx.se?subject=help>
List-Subscribe: <https://cool.haxx.se/cgi-bin/mailman/listinfo/libssh2-devel>, 
 <mailto:libssh2-devel-request@cool.haxx.se?subject=subscribe>
Reply-To: libssh2 development <libssh2-devel@cool.haxx.se>
Content-Type: text/plain; charset="utf-8"
Errors-To: libssh2-devel-bounces@cool.haxx.se
Sender: "libssh2-devel" <libssh2-devel-bounces@cool.haxx.se>
Content-Transfer-Encoding: 8bit
X-MIME-Autoconverted: from base64 to 8bit by giant.haxx.se id x7D7bqCT018950

Leo in gmane.network.ssh.libssh2.devel (Fri, 9 Aug 2019 22:34:59 -0400):
>But the crash happens when the operation is passed to libssh2. So my 
>only hope that someone here will be able to decipher the errors I see in 
>Xcode debugger.

These were the errors you reported to see in Xcode debugger:

#if OPENSSL_VERSION_NUMBER >= 0x10100000L && \
 ?????? !defined(LIBRESSL_VERSION_NUMBER)
 ?????? #ifndef OPENSSL_NO_ENGINE
 ??????????????
ENGINE_load_builtin_engines();?????????????????????????????????? <--
Thread 8: 
EXC_BAD_ACCESS (code=1, address=0x116)
 ?????????????? ENGINE_register_all_complete();
 ?????? #endif

Libssh2 does not need any engine, so it is safe to remove both
ENGINE_load_builtin_engines() and ENGINE_register_all_complete() by
applying this patch in src/openssl.h:
https://github.com/Jan-E/iSSH2/commit/6b2b61d56fc43642980aacc529c9d9d14263cebf#diff-47bf3a78aa165576c6c85a942ddf572bR1

Please recompile your libssh2.a after that patch and report back if the
app still crashes and what Xcode debugger reports then. It cannot be the
same as the message above, because those lines do not exist anymore.
-- 
Jan

_______________________________________________
libssh2-devel https://cool.haxx.se/cgi-bin/mailman/listinfo/libssh2-devel

From libssh2-devel-bounces@cool.haxx.se  Tue Aug 13 09:56:16 2019
Return-Path: <libssh2-devel-bounces@cool.haxx.se>
Received: from www.haxx.se (mail [127.0.0.1])
	by giant.haxx.se (8.15.2/8.15.2/Debian-4) with ESMTP id x7D7u1Wo031926;
	Tue, 13 Aug 2019 09:56:12 +0200
Received: from blaine.gmane.org (195-159-176-226.customer.powertech.no
 [195.159.176.226])
 by giant.haxx.se (8.15.2/8.15.2/Debian-4) with ESMTPS id x7D7u0EY031908
 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT)
 for <libssh2-devel@cool.haxx.se>; Tue, 13 Aug 2019 09:56:00 +0200
Received: from list by blaine.gmane.org with local (Exim 4.89)
 (envelope-from <gnslg-libssh2-devel-2@m.gmane.org>)
 id 1hxRey-0001Xi-Gy
 for libssh2-devel@cool.haxx.se; Tue, 13 Aug 2019 09:56:00 +0200
X-Injected-Via-Gmane: http://gmane.org/
To: libssh2-devel@cool.haxx.se
From: Jan Ehrhardt <phpdev@ehrhardt.nl>
Subject: Re: libssh crash on Mac
Date: Tue, 13 Aug 2019 09:55:53 +0200
Message-ID: <g4r4letus8gvkn9glddt82jol9vt6e4htu@4ax.com>
References: <34d20f30-473f-c317-d5f3-cce8bf3f7c60@rogers.com>
 <0e7652e3-59f2-6864-dc5a-530e686ad40b@rogers.com>
 <20190504225817.8009.qmail@stuge.se>
 <20190504225817.8009.qmail-Y+HMSxxDrH8@public.gmane.org>
 <a4f3646f-0edb-59b4-b20c-410515e94170@rogers.com>
 <efppkedcf1pj1khq8padeied76lhr9814u@4ax.com>
 <efppkedcf1pj1khq8padeied76lhr9814u-e09XROE/p8c@public.gmane.org>
 <dbf3c21a-2809-c6ff-f8e3-7fffe3869514@rogers.com>
 <6gp4lepeo80e1mde9o2cvhiknr911pn9kj@4ax.com>
Mime-Version: 1.0
X-Newsreader: Forte Agent 3.3/32.846
X-BeenThere: libssh2-devel@cool.haxx.se
X-Mailman-Version: 2.1.22
Precedence: list
List-Id: libssh2 development <libssh2-devel.cool.haxx.se>
List-Unsubscribe: <https://cool.haxx.se/cgi-bin/mailman/options/libssh2-devel>, 
 <mailto:libssh2-devel-request@cool.haxx.se?subject=unsubscribe>
List-Archive: <http://cool.haxx.se/pipermail/libssh2-devel/>
List-Post: <mailto:libssh2-devel@cool.haxx.se>
List-Help: <mailto:libssh2-devel-request@cool.haxx.se?subject=help>
List-Subscribe: <https://cool.haxx.se/cgi-bin/mailman/listinfo/libssh2-devel>, 
 <mailto:libssh2-devel-request@cool.haxx.se?subject=subscribe>
Reply-To: libssh2 development <libssh2-devel@cool.haxx.se>
Content-Type: text/plain; charset="utf-8"
Errors-To: libssh2-devel-bounces@cool.haxx.se
Sender: "libssh2-devel" <libssh2-devel-bounces@cool.haxx.se>
Content-Transfer-Encoding: 8bit
X-MIME-Autoconverted: from base64 to 8bit by giant.haxx.se id x7D7u1Wo031926

Jan Ehrhardt in gmane.network.ssh.libssh2.devel (Tue, 13 Aug 2019
09:37:40 +0200):
>Leo in gmane.network.ssh.libssh2.devel (Fri, 9 Aug 2019 22:34:59 -0400):
>>But the crash happens when the operation is passed to libssh2. So my 
>>only hope that someone here will be able to decipher the errors I see in 
>>Xcode debugger.
>
>These were the errors you reported to see in Xcode debugger:
>
>#if OPENSSL_VERSION_NUMBER >= 0x10100000L && \
> ?????? !defined(LIBRESSL_VERSION_NUMBER)
> ?????? #ifndef OPENSSL_NO_ENGINE
> ??????????????
>ENGINE_load_builtin_engines();?????????????????????????????????? <--
>Thread 8: 
>EXC_BAD_ACCESS (code=1, address=0x116)
> ?????????????? ENGINE_register_all_complete();
> ?????? #endif

In libssh2 1.9.0+ you could also recompile with a defined
OPENSSL_NO_ENGINE.
-- 
Jan

_______________________________________________
libssh2-devel https://cool.haxx.se/cgi-bin/mailman/listinfo/libssh2-devel

From libssh2-devel-bounces@cool.haxx.se  Tue Aug 13 14:07:16 2019
Return-Path: <libssh2-devel-bounces@cool.haxx.se>
Received: from www.haxx.se (mail [127.0.0.1])
	by giant.haxx.se (8.15.2/8.15.2/Debian-4) with ESMTP id x7DC6ehk012679;
	Tue, 13 Aug 2019 14:07:05 +0200
Received: from foo.stuge.se (foo.stuge.se [212.116.89.98])
 by giant.haxx.se (8.15.2/8.15.2/Debian-4) with ESMTPS id x7DC6d7Z012487
 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT)
 for <libssh2-devel@cool.haxx.se>; Tue, 13 Aug 2019 14:06:39 +0200
Received: (qmail 28409 invoked by uid 1000); 13 Aug 2019 12:06:34 -0000
Message-ID: <20190813120634.28408.qmail@stuge.se>
Date: Tue, 13 Aug 2019 12:06:34 +0000
From: Peter Stuge <peter@stuge.se>
To: libssh2 development <libssh2-devel@cool.haxx.se>
Subject: Re: libssh crash on Mac
MIME-Version: 1.0
Content-Disposition: inline
In-Reply-To: <g4r4letus8gvkn9glddt82jol9vt6e4htu@4ax.com>
 <6gp4lepeo80e1mde9o2cvhiknr911pn9kj@4ax.com>
X-BeenThere: libssh2-devel@cool.haxx.se
X-Mailman-Version: 2.1.22
Precedence: list
List-Id: libssh2 development <libssh2-devel.cool.haxx.se>
List-Unsubscribe: <https://cool.haxx.se/cgi-bin/mailman/options/libssh2-devel>, 
 <mailto:libssh2-devel-request@cool.haxx.se?subject=unsubscribe>
List-Archive: <http://cool.haxx.se/pipermail/libssh2-devel/>
List-Post: <mailto:libssh2-devel@cool.haxx.se>
List-Help: <mailto:libssh2-devel-request@cool.haxx.se?subject=help>
List-Subscribe: <https://cool.haxx.se/cgi-bin/mailman/listinfo/libssh2-devel>, 
 <mailto:libssh2-devel-request@cool.haxx.se?subject=subscribe>
Reply-To: libssh2 development <libssh2-devel@cool.haxx.se>
Content-Type: text/plain; charset="utf-8"
Errors-To: libssh2-devel-bounces@cool.haxx.se
Sender: "libssh2-devel" <libssh2-devel-bounces@cool.haxx.se>
Content-Transfer-Encoding: 8bit
X-MIME-Autoconverted: from base64 to 8bit by giant.haxx.se id x7DC6ehk012679

Jan Ehrhardt wrote:
> Libssh2 does not need any engine, so it is safe to remove both
> ENGINE_load_builtin_engines() and ENGINE_register_all_complete() by
> applying this patch in src/openssl.h:
> https://github.com/Jan-E/iSSH2/commit/6b2b61d56fc43642980aacc529c9d9d14263cebf#diff-47bf3a78aa165576c6c85a942ddf572bR1
..
> In libssh2 1.9.0+ you could also recompile with a defined
> OPENSSL_NO_ENGINE.

True as that may be, it merely papers over the actual programming error.

OpenSSL wouldn't crash unless it is being called in a wrong way, through
libssh2.

In particular, libssh2_init(3) notes that the function is not thread
safe. Leos test case in a minimal SFTP application working well
suggests that a complexity in the full application causes the crash.

Multiple threads are a fairly likely candidate, but no matter what the
cause is, ensuring that libssh2_init() is only called a single time on
startup could solve the problem properly.


//Peter
_______________________________________________
libssh2-devel https://cool.haxx.se/cgi-bin/mailman/listinfo/libssh2-devel

From libssh2-devel-bounces@cool.haxx.se  Mon Aug 19 07:51:20 2019
Return-Path: <libssh2-devel-bounces@cool.haxx.se>
Received: from www.haxx.se (mail [127.0.0.1])
	by giant.haxx.se (8.15.2/8.15.2/Debian-4) with ESMTP id x7J5oWWg007449;
	Mon, 19 Aug 2019 07:51:09 +0200
Received: from sonic308-13.consmr.mail.ne1.yahoo.com
 (sonic308-13.consmr.mail.ne1.yahoo.com [66.163.187.36])
 by giant.haxx.se (8.15.2/8.15.2/Debian-4) with ESMTPS id x7J5oSoo007048
 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128 verify=NOT)
 for <libssh2-devel@cool.haxx.se>; Mon, 19 Aug 2019 07:50:29 +0200
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=rogers.com; s=s2048;
 t=1566193821; b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DQCI3YJHkFtjMEILjNN5CodK6RsAoiYq0z6dTdr0CNdtBeF4rHmf8myCP7Jx6t
 xWRtpb.Jn8mNgqK7Re5ugkmMT9sjeUJz7ML_nn8wZCTd0egGQ88ajE0y6yc80q6A.m7uneZSqmlf
 vfit4Dw33fp_ifmmLX.VYXo3UChiEKghwq40UaB_OFNvsXDN1aWyUYC5630vTZs.W_UwTxm9ZgDc
 fBWlsn9F8kFMtqQmIdIhzPTuEVaNrw1ZsUJYi49Gi7c4SqHtuI2Fj6PKcZUj2jo1XR__acYH9GBF
 AdIvEGbyhGh9Op9GC1XGyzdjs.DOSS3dSz67rmnrygsIB3e9OGRYS3PIVAWlhG__wmksok10if3T
 GHjezYT1ZcvRzE02lkd3aPAnK31iXbb3lZgJvl_pjHF5I8hylCfn2TGy9S3pxZRuKUfzpuiNS2rl
 zr2XhuJtoSNub7brzTVYc6OznW.Z6QGJkqbtVdb6Wb9PHh9J2XTc2QTXkxGOhNadBTFGIbqmxMWE
 M7_4hb0xaKLrXEg0XcwJ3AXuTpBLQ.1MD_i1RX_KPT8dfYbKUMMLCEKDgTJtevCPEWvBS6jV.Liu
 S9S3dRcX_axCLwcTCcxGLH3Rcf1p21LRX61DKEFv98zHmRcyc5R73OYCN8LM.Ech.S.H3WwDVcHY
 SBcNCluhzhzPRajUlQdwB53tp3oWU5xE9awR6mRM-
Received: from sonic.gate.mail.ne1.yahoo.com by
 sonic308.consmr.mail.ne1.yahoo.com with HTTP; Mon, 19 Aug 2019 05:50:21 +0000
Received: by smtp409.mail.ne1.yahoo.com (Oath Hermes SMTP Server) with ESMTPA
 ID 03e3a1d8551e1ab3c245de156fee5c4e; 
 Mon, 19 Aug 2019 05:50:17 +0000 (UTC)
Subject: Re: libssh crash on Mac
References: <06f444aa-383a-8431-9da0-0f1f8cd51e07@rogers.com>
 <20190307112528.18089.qmail@stuge.se>
 <34d20f30-473f-c317-d5f3-cce8bf3f7c60@rogers.com>
 <0e7652e3-59f2-6864-dc5a-530e686ad40b@rogers.com>
 <20190504225817.8009.qmail@stuge.se>
 <a4f3646f-0edb-59b4-b20c-410515e94170@rogers.com>
 <20190811224807.30303.qmail@stuge.se>
From: Leo <leo.r@rogers.com>
To: libssh2 development <libssh2-devel@cool.haxx.se>
Message-ID: <a5c1b77a-cd31-b3ba-3baf-62eb19ea4f6d@rogers.com>
Date: Mon, 19 Aug 2019 01:50:16 -0400
User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.14; rv:60.0)
 Gecko/20100101 Thunderbird/60.8.0
MIME-Version: 1.0
In-Reply-To: <20190811224807.30303.qmail@stuge.se>
Content-Language: en-US
X-BeenThere: libssh2-devel@cool.haxx.se
X-Mailman-Version: 2.1.22
Precedence: list
List-Id: libssh2 development <libssh2-devel.cool.haxx.se>
List-Unsubscribe: <https://cool.haxx.se/cgi-bin/mailman/options/libssh2-devel>, 
 <mailto:libssh2-devel-request@cool.haxx.se?subject=unsubscribe>
List-Archive: <http://cool.haxx.se/pipermail/libssh2-devel/>
List-Post: <mailto:libssh2-devel@cool.haxx.se>
List-Help: <mailto:libssh2-devel-request@cool.haxx.se?subject=help>
List-Subscribe: <https://cool.haxx.se/cgi-bin/mailman/listinfo/libssh2-devel>, 
 <mailto:libssh2-devel-request@cool.haxx.se?subject=subscribe>
Reply-To: libssh2 development <libssh2-devel@cool.haxx.se>
Content-Type: text/plain; charset="utf-8"; Format="flowed"
Errors-To: libssh2-devel-bounces@cool.haxx.se
Sender: "libssh2-devel" <libssh2-devel-bounces@cool.haxx.se>
Content-Transfer-Encoding: 8bit
X-MIME-Autoconverted: from base64 to 8bit by giant.haxx.se id x7J5oWWg007449

On 8/11/19 6:48 PM, Peter Stuge wrote:
> Hi Leo,
>
> Leo wrote:
>> Now when I try to connect to SFTP site, the crash produces the following
>> output in Xcode debugger:
>>
>> openssl.c > _libssh2_openssl_crypto_init()
>>
>>
>> #if OPENSSL_VERSION_NUMBER >= 0x10100000L && \
>>   ?????? !defined(LIBRESSL_VERSION_NUMBER)
>>   ?????? #ifndef OPENSSL_NO_ENGINE
>>   ?????????????? ENGINE_load_builtin_engines();?????????????????????????????????? <-- Thread 8:
>> EXC_BAD_ACCESS (code=1, address=0x116)
>>   ?????????????? ENGINE_register_all_complete();
>>   ?????? #endif
>>
> I guess that OpenSSL was somehow already initialized, and the crash
> happens becuse OpenSSL does not support being initialized twice.
>
> If this is the case, please move or add the libssh2_init() call into your
> application startup, immediately on startup, before any user interaction.
>
> Then only call libssh2_session_init() in your SFTP constructor.
>
> Let me know how it goes.
>

Thanks Peter,

I followed your suggestion...

I added the libssh2_init() call to my app startup, which resulted in the 
same crash BUT the macOS crash report produced this time contained some 
info that nudged me to the right direction - which eventually helped 
solve the issue.

Bottom line: the issue is solved - and I'm grateful for all the feedback 
I received here.


Now, I don't have a single answer as to what caused the issue - as it 
seems to be different for two Xcode projects of the same app (which 
contain different versions of libssh2). I hope to find the least 
confusing way of describing it, if anyone is curious:


Last year, I adopted a new licensing system (namely SoftwareKey.com - 
which is a great licensing platform btw). The aforementioned crash log 
mentioned the new licensing framework (.framework) I'm using in my apps.

I went through SoftwareKey's downloads again and found out that they 
specifically mention that their libraries use libssl/libcrypto (as well 
as libcurl and libxml). And that it can cause conflicts if the host app 
is also using those libraries. For which purpose they also include a 
"no-dependencies" .a library which, naturally, doesn't include those 
3rd-party libs - and will rely on those linked to the host app.

I didn't use that library. I was using their .framework framework in all 
apps (which framework includes all 3rd-party dependencies).

While it sounds like the obvious answer to my issue, it's only partially so.

After hours of testing I now have two cases:


CASE 1

-My original Xcode project which uses libssh2-1.4.3 (in a form of a 
folder with source files)

-I replaced the licensing .framework with their "no-dependencies" .a lib.

-It SOLVED the SFTP crashes issue.

-I also can build the project with or without the licensing library.

Pretty straightforward - and I'm fine with using older libssh2 version 
as long as it works.


CASE 2

-My updated Xcode project with the recent version, libssh2-1.9.0, as a 
.a library.

-Replacing licensing .framework with the "no-dependencies" lib does NOT 
help. In fact it causes build errors that prevent from compiling the app 
at all.

-If I just remove the licensing .framework without replacing it with 
anything else, I still cannot build the app due to the same build 
errors. That is, I can only compile the app with the licensing framework 
present.

-However, I did solve the SFTP crashes in this project too - but this 
time by relinking to a newer libcrypto library (something gave me a hint 
that libcrypto is at fault for something).

-Therefore, I do have a working app - which, however, cannot be compiled 
without the licensing framework.


If it makes any difference, the build errors I mentioned above are 
related to libssl:

Undefined symbol: _EVP_CIPHER_CTX_cleanup
Undefined symbol: _EVP_CIPHER_CTX_init


I'll be in touch regarding those errors with SoftwareKey.

Thanks again for all the help!


Leo


_______________________________________________
libssh2-devel https://cool.haxx.se/cgi-bin/mailman/listinfo/libssh2-devel

