|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
[2018-10-31 10:00 UTC] phpnetbug at netcode dot fi
[2019-08-23 18:49 UTC] z-craig at submeter dot com
[2020-08-21 18:28 UTC] jonathan dot m dot blackburn at gmail dot com
[2021-02-09 17:18 UTC] cmb@php.net
-Status: Open
+Status: Duplicate
-Assigned To:
+Assigned To: cmb
[2021-02-09 17:18 UTC] cmb@php.net
|
|||||||||||||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Sun Nov 02 05:00:01 2025 UTC |
Description: ------------ apt-cache show php-ssh2 Version: 1.1.2+0.13-1+ubuntu16.04.1+deb.sury.org+1 php --version PHP 7.2.5-1+ubuntu16.04.1+deb.sury.org+1 (cli) (built: May 5 2018 04:59:13) ( NTS ) uname -a Linux chef 4.4.0-127-generic #153-Ubuntu SMP Sat May 19 10:58:46 UTC 2018 x86_64 x86_64 x86_64 GNU/Linux cat /etc/os-release NAME="Ubuntu" VERSION="16.04.4 LTS (Xenial Xerus)" variables_order = "EGPCS" Can be reproduced at will. Please let me know what you need for additional information... Test script: --------------- <?php // touch /tmp/test $aArchiveDestination = array('host' => '127.0.0.1', 'port' => 22, 'user' => 'mybackup', 'path' => '/home/mybackup', 'scheme' => 'sftp'); $aOptions = array('policy' => 'daily'); $file = '/tmp/test'; /* php -f coredump.php Archiving /tmp/test to sftp://mybackup@127.0.0.1:/home/mybackup/daily/testbefore fopen before fwrite Segmentation fault (core dumped) */ $lSshConnection = ssh2_connect($aArchiveDestination['host'], $aArchiveDestination['port']); $aUserInfo = posix_getpwuid(posix_getuid()); $lPubKeyFile = $aUserInfo['dir'] . '/.ssh/id_rsa.pub'; $lPrivKeyFile = $aUserInfo['dir'] . '/.ssh/id_rsa'; $lPassPhrase = ''; if ( ! ssh2_auth_pubkey_file($lSshConnection, $aArchiveDestination['user'], $lPubKeyFile, $lPrivKeyFile, $lPassPhrase) ) { $rc = 9999; $msg = ' ERROR: Public Key Authentication on host ' . $aArchiveDestination['host'] . ' failed.' . " (rc=$rc)"; throw new Exception($msg); } $dst = $aArchiveDestination['path'] . '/' . $aOptions['policy'] . '/' . basename($file); printf(" Archiving $file to " . $aArchiveDestination['scheme'] . '://' . $aArchiveDestination['user'] . '@' . $aArchiveDestination['host'] . ':' . $dst); $sftp = ssh2_sftp($lSshConnection); // @fopen echo "before fopen\n"; // Here we have the segementation!!!! // See also comment here: http://www.php.net/manual/en/function.ssh2-scp-send.php // https://stackoverflow.com/questions/7414175/php-sftp-seg-fault $stream = fopen('ssh2.sftp://' . intval($sftp) . $dst, 'w'); if ( ! $stream ) { $rc = 9999; $msg = " ERROR: Could not open file: $dst" . " (rc=$rc)"; throw new Exception($msg); } if ( ! array_key_exists('simulate', $aOptions) ) { $lDataToSend = @file_get_contents($file); if ( $lDataToSend === false ) { $rc = 9999; $msg = " ERROR: Could not open local file: $file." . " (rc=$rc)"; throw new Exception($msg); } echo "before fwrite\n"; if ( @fwrite($stream, $lDataToSend) === false ) { $rc = 9999; $msg = " ERROR: Could not send data from file: $file." . " (rc=$rc)"; throw new Exception($msg); } @fclose($stream); } ssh2_disconnect($lSshConnection); ?> Expected result: ---------------- No: php -f coredump.php Archiving /tmp/test to sftp://mybackup@127.0.0.1:/home/mybackup/daily/testbefore fopen before fwrite Segmentation fault (core dumped) Actual result: -------------- warning: core file may not match specified executable file. [New LWP 31163] [Thread debugging using libthread_db enabled] Using host libthread_db library "/lib/x86_64-linux-gnu/libthread_db.so.1". Core was generated by `php -f coredump.php'. Program terminated with signal SIGSEGV, Segmentation fault. #0 0x00007fdac86e0900 in ?? () from /usr/lib/x86_64-linux-gnu/libssh2.so.1 (gdb) bt #0 0x00007fdac86e0900 in ?? () from /usr/lib/x86_64-linux-gnu/libssh2.so.1 #1 0x00007fdac86eccd5 in libssh2_sftp_shutdown () from /usr/lib/x86_64-linux-gnu/libssh2.so.1 #2 0x00007fdac890e973 in php_ssh2_sftp_dtor () from /usr/lib/php/20170718/ssh2.so #3 0x000055e161e283d1 in ?? () #4 0x000055e161e28423 in ?? () #5 0x000055e161e258d0 in zend_hash_reverse_apply () #6 0x000055e161e00e30 in ?? () #7 0x000055e161e1285b in zend_deactivate () #8 0x000055e161dac8da in php_request_shutdown () #9 0x000055e161ec5a7c in ?? () #10 0x000055e161c62e2c in ?? () #11 0x00007fdacef0b830 in __libc_start_main (main=0x55e161c629b0, argc=3, argv=0x7fffbb6d56c8, init=<optimised out>, fini=<optimised out>, rtld_fini=<optimised out>, stack_end=0x7fffbb6d56b8) at ../csu/libc-start.c:291 #12 0x000055e161c62f49 in _start ()