swoole-src icon indicating copy to clipboard operation
swoole-src copied to clipboard

openssl 1.1.1n error

Open AngusDV opened this issue 2 years ago • 12 comments

my program run without SWOOLE_SSL but when i am use SWOOLE_SSL get error Segmentation fault. Please answer these questions before submitting your issue.

What did you do? If possible, provide a simple script for reproducing the error.

$server = new Server("0.0.0.0", 9502, SWOOLE_PROCESS,SWOOLE_SOCK_TCP | SWOOLE_SSL);
$server->set([
'daemonize' => false,
'ssl_verify_peer' => true,
'dispatch_mode' => 2,
'debug_mode' => 1,
'open_websocket_protocol' => true,
'log_file' => "./swoole.log",
'buffer_output_size' => 32 * 1024 * 1024,
'ssl_cert_file' => env('WS_SSL_CERT_FILE'),
'ssl_key_file' => env('WS_SSL_KEY_FILE'),
]);

What did you expect to see? just run

What did you see instead?

[root@vps1708 panel]# gdb php -c core.12620
GNU gdb (GDB) Red Hat Enterprise Linux 7.6.1-120.el7
Copyright (C) 2013 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later http://gnu.org/licenses/gpl.html
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law. Type "show copying"
and "show warranty" for details.
This GDB was configured as "x86_64-redhat-linux-gnu".
For bug reporting instructions, please see:
http://www.gnu.org/software/gdb/bugs/...
"/usr/local/bin/php": not in executable format: File format not recognized
[New LWP 12620]
Missing separate debuginfo for the main executable file
Try: yum --enablerepo='debug' install /usr/lib/debug/.build-id/9c/1874600eef209dc28a768a2cbd7528cc807b55
Core was generated by `ea-php80 artisan swoole:serve'.
Program terminated with signal 11, Segmentation fault.
#0 0x00007fbdc313ebc0 in ?? ()
(gdb) bt
#0 0x00007fbdc313ebc0 in ?? ()
#1 0x00007fbdbedbda9d in ?? ()

What version of Swoole are you using (show your php --ri swoole)? swoole

Swoole => enabled Author => Swoole Team [email protected] Version => 4.8.8 Built => Mar 31 2022 09:09:00 coroutine => enabled with boost asm context epoll => enabled eventfd => enabled signalfd => enabled cpu_affinity => enabled spinlock => enabled rwlock => enabled sockets => enabled openssl => OpenSSL 1.1.1n 15 Mar 2022 dtls => enabled http2 => enabled json => enabled curl-native => enabled pcre => enabled zlib => 1.2.7 mutex_timedlock => enabled pthread_barrier => enabled futex => enabled mysqlnd => enabled async_redis => enabled

Directive => Local Value => Master Value swoole.enable_coroutine => On => On swoole.enable_library => On => On swoole.enable_preemptive_scheduler => Off => Off swoole.display_errors => On => On swoole.use_shortname => On => On swoole.unixsock_buffer_size => 8388608 => 8388608

What is your machine environment used (show your uname -a & php -v & gcc -v) ? Operating System: CentOS Linux 7 (Core) CPE OS Name: cpe:/o:centos:centos:7 Kernel: Linux 3.10.0-1160.59.1.el7.x86_64 Architecture: x86-64 PHP 8.0.17 (cli) (built: Mar 23 2022 07:36:32) ( NTS ) Copyright (c) The PHP Group Zend Engine v4.0.17, Copyright (c) Zend Technologies with Zend OPcache v8.0.17, Copyright (c), by Zend Technologies Using built-in specs. COLLECT_GCC=gcc COLLECT_LTO_WRAPPER=/usr/libexec/gcc/x86_64-redhat-linux/4.8.5/lto-wrapper Target: x86_64-redhat-linux Configured with: ../configure --prefix=/usr --mandir=/usr/share/man --infodir=/usr/share/info --with-bugurl=http://bugzilla.redhat.com/bugzilla --enable-bootstrap --enable-shared --enable-threads=posix --enable-checking=release --with-system-zlib --enable-__cxa_atexit --disable-libunwind-exceptions --enable-gnu-unique-object --enable-linker-build-id --with-linker-hash-style=gnu --enable-languages=c,c++,objc,obj-c++,java,fortran,ada,go,lto --enable-plugin --enable-initfini-array --disable-libgcj --with-isl=/builddir/build/BUILD/gcc-4.8.5-20150702/obj-x86_64-redhat-linux/isl-install --with-cloog=/builddir/build/BUILD/gcc-4.8.5-20150702/obj-x86_64-redhat-linux/cloog-install --enable-gnu-indirect-function --with-tune=generic --with-arch_32=x86-64 --build=x86_64-redhat-linux Thread model: posix gcc version 4.8.5 20150623 (Red Hat 4.8.5-44) (GCC)

AngusDV avatar Mar 31 '22 13:03 AngusDV

I cannot reproduce, Please use valgrind to track memory errors

USE_ZEND_ALLOC=0 valgrind php your_file.php

matyhtf avatar Apr 27 '22 07:04 matyhtf

[root@vps1708 panel]# USE_ZEND_ALLOC=0 valgrind php artisan swoole:serve ==13892== Memcheck, a memory error detector ==13892== Copyright (C) 2002-2017, and GNU GPL'd, by Julian Seward et al. ==13892== Using Valgrind-3.15.0 and LibVEX; rerun with -h for copyright info ==13892== Command: /usr/local/bin/php artisan swoole:serve ==13892== Segmentation fault

AngusDV avatar Apr 28 '22 00:04 AngusDV

What kind of php framework do you use ? laravelS or laravel octane?

NathanFreeman avatar Apr 28 '22 01:04 NathanFreeman

I do not use any of them I only use it on the Laravel console

AngusDV avatar Apr 28 '22 01:04 AngusDV

I can not reproduce it. It work without issue on my server. But the bt you provide is empty and I guess there is something wrong with your php. Have you tested it on other servers?

NathanFreeman avatar Apr 28 '22 03:04 NathanFreeman

i am tested in another server with nginx and i haven't problem with that . i have problem after upgrade openssl.

AngusDV avatar Apr 28 '22 06:04 AngusDV

Have you tried to re-compile the Swoole extension after you upgraded the OpenSSL? You should re-compile it from the beginning, execute the make clean command, then phpize, configure, make, make install...

twose avatar Apr 28 '22 06:04 twose

升级 OpenSSL 后是否尝试过重新编译 Swoole 扩展? 您应该从头重新编译它,执行make clean命令,然后phpize, configure, make, make install...

An error occurred on the HTTP client request.

[2022-04-28 16:43:29 @15303.0]	NOTICE	Socket::ssl_connect(fd=12) to server[0.0.0.0:32949] failed. Error: error:1409442E:SSL routines:ssl3_read_bytes:tlsv1 alert protocol version[1|1070]

Alion548 avatar Apr 28 '22 08:04 Alion548

@Alion548 What is the openssl version after upgrading?

NathanFreeman avatar Apr 28 '22 09:04 NathanFreeman

What is the openssl version after upgrading?

openssl version
OpenSSL 3.0.2 15 Mar 2022 (Library: OpenSSL 3.0.2 15 Mar 2022)

php --ri swoole

swoole

Swoole => enabled
Author => Swoole Team <[email protected]>
Version => 4.8.9
Built => Apr 28 2022 17:14:04
coroutine => enabled with boost asm context
epoll => enabled
eventfd => enabled
signalfd => enabled
cpu_affinity => enabled
spinlock => enabled
rwlock => enabled
openssl => OpenSSL 3.0.2 15 Mar 2022
dtls => enabled
http2 => enabled
pcre => enabled
c-ares => 1.17.2
zlib => 1.2.11
brotli => E16777225/D16777225
mutex_timedlock => enabled
pthread_barrier => enabled
futex => enabled
async_redis => enabled

Directive => Local Value => Master Value
swoole.enable_coroutine => On => On
swoole.enable_library => On => On
swoole.enable_preemptive_scheduler => Off => Off
swoole.display_errors => On => On
swoole.use_shortname => Off => Off
swoole.unixsock_buffer_size => 8388608 => 8388608

Alion548 avatar Apr 28 '22 09:04 Alion548

Please checking the list of tls versions that openssl support.

openssl s_client -help 2>&1 | awk '/-(ssl|tls)[0-9]/{print $1}'

NathanFreeman avatar Apr 28 '22 09:04 NathanFreeman

Please checking the list of tls versions that openssl support.

openssl s_client -help 2>&1 | awk '/-(ssl|tls)[0-9]/{print $1}'

openssl s_client -help 2>&1 | awk '/-(ssl|tls)[0-9]/{print $1}' -tls1 -tls1_1 -tls1_2 -tls1_3

Alion548 avatar Apr 28 '22 09:04 Alion548