Chilkat php Разбитая труба - PullRequest
0 голосов
/ 28 мая 2019

Моя среда: Убутну сервер 18.04 64бит PHP 7.2.2 ZTS без отладки

Скрипт, работающий в режиме многопоточности. Каждый скрипт имеет собственный объект CkImap.

Я не могу предоставить полный код скрипта, но в этом нет ничего необычного: связь с imap через туннель ssh. Как это:

$this->imap->put_ConnectTimeout(10);
$this->imap->put_Ssl(true);
$this->imap->put_PeekMode(true);
$this->imap->put_Utf8(true);

$this->imap->SshOpenTunnel($proxy->ip, $proxy->port);
$this->imap->SshAuthenticatePw($proxy->username,$proxy->password);

$this->imap->Connect($account->imap_server);
$this->imap->login($account->email, $account->password);

$this->imap->Disconnect();
$this->imap->SshCloseTunnel();

И иногда он падает с thread 42 "php" received signal SIGPIPE, Broken pipe.

Кажется, что происходит сбой при попытке закрыть подключение к imap или закрыть sshTunnel.

Я пытался воспроизвести ошибку, но безуспешно. Пытался звонить imap->Disconnect() и imap->SshCloseTunnel() дважды, но не повезло, без ошибок.

Полная обратная трассировка ядра:

Thread 42 "php" received signal SIGPIPE, Broken pipe.
[Switching to Thread 0x7fff279ff700 (LWP 46139)]
0x00007ffff5ea89ae in __libc_send (fd=169, buf=0x7fff642f5ba0, len=36,
    flags=0) at ../sysdeps/unix/sysv/linux/send.c:28
28  ../sysdeps/unix/sysv/linux/send.c: No such file or directory.
(gdb) bt
#0  0x00007ffff5ea89ae in __libc_send (fd=169, buf=0x7fff642f5ba0, len=36,
    flags=0) at ../sysdeps/unix/sysv/linux/send.c:28
#1  0x00007fffeb919236 in ChilkatSocket::sockSend(unsigned char const*, unsigned int, unsigned int, bool, bool, unsigned int, unsigned int&, LogBase&, SocketParams&) ()
   from /etc/php7/lib/php/extensions/no-debug-zts-20170718/chilkat_9_5_0.so
#2  0x00007fffeb919610 in ChilkatSocket::tcpSendBytes(DataBuffer const&, unsigned int, bool, bool, unsigned int, unsigned int&, LogBase&, SocketParams&) ()
   from /etc/php7/lib/php/extensions/no-debug-zts-20170718/chilkat_9_5_0.so
#3  0x00007fffebab42a9 in TlsEndpoint::tlsSendBytes(DataBuffer const&, unsigned int, bool, unsigned int, unsigned int&, LogBase&, SocketParams&) ()
   from /etc/php7/lib/php/extensions/no-debug-zts-20170718/chilkat_9_5_0.so
#4  0x00007fffeba8ac44 in SshTransport::sendMessageInOnePacket(char const*, char const*, DataBuffer&, unsigned int&, SocketParams&, LogBase&) ()
   from /etc/php7/lib/php/extensions/no-debug-zts-20170718/chilkat_9_5_0.so
#5  0x00007fffeba91648 in SshTransport::channelSendClose2(unsigned int, SocketParams&, LogBase&) ()
   from /etc/php7/lib/php/extensions/no-debug-zts-20170718/chilkat_9_5_0.so
#6  0x00007fffeba97af6 in SshTransport::closeChannel(unsigned int, bool&, SshReadParams&, SocketParams&, LogBase&) ()
   from /etc/php7/lib/php/extensions/no-debug-zts-20170718/chilkat_9_5_0.so
#7  0x00007fffeba78723 in Socket2::sshCloseChannel(SshReadParams&, SocketParams&, LogBase&) ()
   from /etc/php7/lib/php/extensions/no-debug-zts-20170718/chilkat_9_5_0.so
#8  0x00007fffebab4c15 in TlsEndpoint::sshCloseChannel(SshReadParams&, SocketParams&, LogBase&) ()
   from /etc/php7/lib/php/extensions/no-debug-zts-20170718/chilkat_9_5_0.so
#9  0x00007fffebb5c65f in SChannelChilkat::sshCloseChannel(SshReadParams&, SocketParams&, LogBase&) ()
   from /etc/php7/lib/php/extensions/no-debug-zts-20170718/chilkat_9_5_0.so
---Type <return> to continue, or q <return> to quit---
#10 0x00007fffeba787db in Socket2::sshCloseChannel(SshReadParams&, SocketParams&, LogBase&) ()
   from /etc/php7/lib/php/extensions/no-debug-zts-20170718/chilkat_9_5_0.so
#11 0x00007fffeba7947a in Socket2::sockClose(bool, bool, unsigned int, LogBase&, ProgressMonitor*, bool) ()
   from /etc/php7/lib/php/extensions/no-debug-zts-20170718/chilkat_9_5_0.so
#12 0x00007fffeb9cc60b in _ckImap::handleSocketFailure() ()
   from /etc/php7/lib/php/extensions/no-debug-zts-20170718/chilkat_9_5_0.so
#13 0x00007fffeb9cc928 in _ckImap::getServerResponseLine2(StringBuffer&, LogBase&, SocketParams&) ()
   from /etc/php7/lib/php/extensions/no-debug-zts-20170718/chilkat_9_5_0.so
#14 0x00007fffeb9cd104 in _ckImap::getCompleteResponse(char const*, ExtPtrArraySb&, LogBase&, SocketParams&) ()
   from /etc/php7/lib/php/extensions/no-debug-zts-20170718/chilkat_9_5_0.so
#15 0x00007fffeb9cf749 in _ckImap::cmdNoArgs(char const*, ImapResultSet&, LogBase&, SocketParams&) ()
   from /etc/php7/lib/php/extensions/no-debug-zts-20170718/chilkat_9_5_0.so
#16 0x00007fffeb79bc59 in ClsImap::closeMailbox(XString&, SocketParams&, LogBase&) ()
   from /etc/php7/lib/php/extensions/no-debug-zts-20170718/chilkat_9_5_0.so
#17 0x00007fffeb7a07ae in ClsImap::CloseMailbox(XString&, ProgressEvent*)
    ()
   from /etc/php7/lib/php/extensions/no-debug-zts-20170718/chilkat_9_5_0.so
#18 0x00007fffeb66739d in CkImap::CloseMailbox(char const*) ()
   from /etc/php7/lib/php/extensions/no-debug-zts-20170718/chilkat_9_5_0.so
#19 0x00007fffeb39aedd in _wrap_CkImap_CloseMailbox ()
   from /etc/php7/lib/php/extensions/no-debug-zts-20170718/chilkat_9_5_0.so
#20 0x0000555555c41b13 in ZEND_DO_FCALL_SPEC_RETVAL_USED_HANDLER ()
    at /var/www/interceptor/php-src-php-7.2.2/Zend/zend_vm_execute.h:1032
#21 execute_ex (ex=0xa9)
    at /var/www/interceptor/php-src-php-7.2.2/Zend/zend_vm_execute.h:59752
---Type <return> to continue, or q <return> to quit---
#22 0x00007fffeac4ba15 in pthreads_execute_ex (data=<optimized out>)
    at /var/www/interceptor.cmd.source/pthreads/php_pthreads.c:135
#23 0x0000555555c3fb5c in ZEND_DO_FCALL_SPEC_RETVAL_UNUSED_HANDLER ()
    at /var/www/interceptor/php-src-php-7.2.2/Zend/zend_vm_execute.h:888
#24 execute_ex (ex=0xa9)
    at /var/www/interceptor/php-src-php-7.2.2/Zend/zend_vm_execute.h:59749
#25 0x00007fffeac4ba15 in pthreads_execute_ex (data=<optimized out>)
    at /var/www/interceptor.cmd.source/pthreads/php_pthreads.c:135
#26 0x0000555555c3fb5c in ZEND_DO_FCALL_SPEC_RETVAL_UNUSED_HANDLER ()
    at /var/www/interceptor/php-src-php-7.2.2/Zend/zend_vm_execute.h:888
#27 execute_ex (ex=0xa9)
    at /var/www/interceptor/php-src-php-7.2.2/Zend/zend_vm_execute.h:59749
#28 0x00007fffeac4ba15 in pthreads_execute_ex (data=<optimized out>)
    at /var/www/interceptor.cmd.source/pthreads/php_pthreads.c:135
#29 0x0000555555c3fb5c in ZEND_DO_FCALL_SPEC_RETVAL_UNUSED_HANDLER ()
    at /var/www/interceptor/php-src-php-7.2.2/Zend/zend_vm_execute.h:888
#30 execute_ex (ex=0xa9)
    at /var/www/interceptor/php-src-php-7.2.2/Zend/zend_vm_execute.h:59749
#31 0x00007fffeac4ba15 in pthreads_execute_ex (data=<optimized out>)
    at /var/www/interceptor.cmd.source/pthreads/php_pthreads.c:135
#32 0x0000555555b7365b in zend_call_function (
    fci=fci@entry=0x7fff279feba0, fci_cache=0x7fff1c9c53a0,
    fci_cache@entry=0x7fff279febd8)
    at /var/www/interceptor/php-src-php-7.2.2/Zend/zend_execute_API.c:819
#33 0x00007fffeac49232 in pthreads_routine_run_function (
    object=object@entry=0x7fffe9f447e0, connection=0x7fff26a68700,
    work=work@entry=0x7fff279fed00)
    at /var/www/interceptor.cmd.source/pthreads/src/object.c:481
#34 0x00007fffeac56aec in pthreads_routine (routine=<optimized out>)
    at /var/www/interceptor.cmd.source/pthreads/src/object.c:516
#35 0x00007ffff5e9e6db in start_thread (arg=0x7fff279ff700)
---Type <return> to continue, or q <return> to quit---
    at pthread_create.c:463
#36 0x00007ffff3d3688f in clone ()
    at ../sysdeps/unix/sysv/linux/x86_64/clone.S:95

Как этого избежать? У меня есть только идея обрабатывать сигналы на PHP, но я не хочу этого делать. Есть ли в Чилкате какой-нибудь способ избежать этого?

...