|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
PatchesPull Requests
Pull requests:
HistoryAllCommentsChangesGit/SVN commits
[2020-05-25 23:03 UTC] info at dotsamazing dot com
[2021-02-09 13:23 UTC] cmb@php.net
-Status: Open
+Status: Analyzed
-Assigned To:
+Assigned To: cmb
[2021-02-09 13:23 UTC] cmb@php.net
[2021-02-09 13:51 UTC] cmb@php.net
[2021-02-24 21:09 UTC] langemeijer@php.net
[2021-02-24 21:09 UTC] langemeijer@php.net
-Status: Analyzed
+Status: Closed
[2021-02-24 21:09 UTC] langemeijer@php.net
|
|||||||||||||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Thu Oct 30 04:00:02 2025 UTC |
Description: ------------ We're using the latest PHP 7.4.3 package under Ubuntu 20.04. While using SSH2 SFTP in a CLI environment, PHP segfaulted after completing the script. Using coredumpctl we've found that the segfault comes from the automatic SSH2 disconnect during PHP teardown. We've isolated the issue and could reproduce it in CLI when calling ssh2_disconnect manually: php: channel.c:2484: _libssh2_channel_free: Assertion `session' failed. However - by calling ssh2_disconnect on the _SFTP handle_ first (!!! it's undocumented and shouldn't be necessary !!!) and ssh2_disconnect on the connection handle next, the script started working fine without any error or segfault. Test script: --------------- $conn = \ssh2_connect( 'example.com', 22, null ); $success = \ssh2_auth_password( $conn, 'username', 'password' ); // init SFTP first to generate $sftp = \ssh2_sftp( $conn ); // uncomment below to avoid segfault // if ( \ssh2_disconnect( $sftp ) !== true ) // throw new Exception('Disconnect SFTP failed'); if ( \ssh2_disconnect( $conn ) !== true ) throw new Exception('Disconnect SSH failed'); Expected result: ---------------- - assertion error shouldn't appear - segmentation fault shouldn't happen - there shouldn't be need for an undocumented disconnect call as a workaround Actual result: -------------- - assertion error and segfault - undocumented disconnect call on an SFTP handle needed before an actual SSH disconnect