[php-src] Issue #12668: ASAN CHECK failed: asan_thread.cpp:368 "((ptr[0] == kCurrentStackFrameMagic)) != (0)" when using PHP fibers

From: Date: Tue, 14 Nov 2023 14:20:09 +0000
Subject: [php-src] Issue #12668: ASAN CHECK failed: asan_thread.cpp:368 "((ptr[0] == kCurrentStackFrameMagic)) != (0)" when using PHP fibers
Groups: php.bugs 
Request: Send a blank email to php-bugs+get-245800@lists.php.net to get a copy of this message
Issue: https://github.com/php/php-src/issues/12668 Author: danog ### Description Hi, we're encountering the following ASAN assertion in our production services (a PHP application that uses fibers). ``` AddressSanitizer: CHECK failed: asan_thread.cpp:368 "((ptr[0] == kCurrentStackFrameMagic)) != (0)" (0x0, 0x0) (tid=1009730) #0 0x7f545fe91b51 (/usr/lib/llvm-16/lib/clang/16/lib/linux/libclang_rt.asan-x86_64.so+0xedb51) (BuildId: 8c0845aee3ffdc74a2f46d1eb4f0a349cdc6> #1 0x7f545fdd68a2 (/usr/lib/llvm-16/lib/clang/16/lib/linux/libclang_rt.asan-x86_64.so+0x328a2) (BuildId: 8c0845aee3ffdc74a2f46d1eb4f0a349cdc6> #2 0x7f545fe95883 (/usr/lib/llvm-16/lib/clang/16/lib/linux/libclang_rt.asan-x86_64.so+0xf1883) (BuildId: 8c0845aee3ffdc74a2f46d1eb4f0a349cdc6> #3 0x7f545fdf8bc7 (/usr/lib/llvm-16/lib/clang/16/lib/linux/libclang_rt.asan-x86_64.so+0x54bc7) (BuildId: 8c0845aee3ffdc74a2f46d1eb4f0a349cdc6> #4 0x7f545fdfa7c3 (/usr/lib/llvm-16/lib/clang/16/lib/linux/libclang_rt.asan-x86_64.so+0x567c3) (BuildId: 8c0845aee3ffdc74a2f46d1eb4f0a349cdc6> #5 0x7f545fe8f71e (/usr/lib/llvm-16/lib/clang/16/lib/linux/libclang_rt.asan-x86_64.so+0xeb71e) (BuildId: 8c0845aee3ffdc74a2f46d1eb4f0a349cdc6> #6 0x7f545fe60c68 in qsort_r (/usr/lib/llvm-16/lib/clang/16/lib/linux/libclang_rt.asan-x86_64.so+0xbcc68) (BuildId: 8c0845aee3ffdc74a2f46d1eb4> #7 0x7f545f5df38a in CRYPTO_free_ex_data (/lib/x86_64-linux-gnu/libcrypto.so.3+0x1bd38a) (BuildId: 156e054fb88f59a4100ca7edc74a79e3908027a8) #8 0x7f545f8a0bb8 in SSL_free (/lib/x86_64-linux-gnu/libssl.so.3+0x39bb8) (BuildId: ce838f6c51f037b73ade040b4abd647d7ae7d62d) #9 0x55d82496299d in php_openssl_sockop_close /root/php-8.2.11/ext/openssl/xp_ssl.c:2252:4 #10 0x55d825971373 in _php_stream_free /root/php-8.2.11/main/streams/streams.c:478:9 #11 0x55d82597b85a in stream_resource_regular_dtor /root/php-8.2.11/main/streams/streams.c:1761:19 #12 0x55d825b673a9 in zend_resource_dtor /root/php-8.2.11/Zend/zend_list.c:73:3 #13 0x55d825b680ef in list_entry_destructor /root/php-8.2.11/Zend/zend_list.c:180:3 #14 0x55d825b53638 in _zend_hash_del_el_ex /root/php-8.2.11/Zend/zend_hash.c:1425:3 #15 0x55d825b556f1 in zend_hash_index_del /root/php-8.2.11/Zend/zend_hash.c:1656:4 #16 0x55d825b67046 in zend_list_free /root/php-8.2.11/Zend/zend_list.c:58:2 #17 0x55d825af0986 in rc_dtor_func /root/php-8.2.11/Zend/zend_variables.c:57:2 #18 0x55d825e779a4 in i_zval_ptr_dtor /root/php-8.2.11/Zend/zend_variables.h:44:4 #19 0x55d825e773bb in zend_object_std_dtor /root/php-8.2.11/Zend/zend_objects.c:70:5 #20 0x55d825e920a5 in zend_objects_store_del /root/php-8.2.11/Zend/zend_objects_API.c:200:4 #21 0x55d825af0986 in rc_dtor_func /root/php-8.2.11/Zend/zend_variables.c:57:2 #22 0x55d825af0a74 in i_zval_ptr_dtor /root/php-8.2.11/Zend/zend_variables.h:44:4 #23 0x55d825af09c4 in zval_ptr_dtor /root/php-8.2.11/Zend/zend_variables.c:84:2 #24 0x55d825b53638 in _zend_hash_del_el_ex /root/php-8.2.11/Zend/zend_hash.c:1425:3 #25 0x55d825b52824 in zend_hash_del /root/php-8.2.11/Zend/zend_hash.c:1495:4 #26 0x55d825caca97 in ZEND_UNSET_DIM_SPEC_VAR_CV_HANDLER /root/php-8.2.11/Zend/zend_vm_execute.h:31516:5 #27 0x55d825baa9fc in execute_ex /root/php-8.2.11/Zend/zend_vm_execute.h:55836:7 #28 0x55d825aaa142 in zend_call_function /root/php-8.2.11/Zend/zend_execute_API.c:949:3 #29 0x55d825ecf5e7 in zend_fiber_execute /root/php-8.2.11/Zend/zend_fibers.c:504:3 #30 0x55d825ecbfae in zend_fiber_trampoline /root/php-8.2.11/Zend/zend_fibers.c:299:2 #31 0x55d82590e1be in trampoline /root/php-8.2.11/Zend/asm/make_x86_64_sysv_elf_gas.S:135 ``` Using PHP 8.2.11 compiled with clang 16 as follows: ``` for t in cli fpm; do export CFLAGS='' export CPPFLAGS='' export CXXFLAGS='' export LDFLAGS='' ./configure --prefix=/usr \ --includedir=/usr/include --mandir=/usr/share/man --infodir=/usr/share/info --sysconfdir=/etc \ --localstatedir=/var --libdir=/usr/lib/x86_64-linux-gnu \ --libexecdir=/usr/lib/x86_64-linux-gnu \ --prefix=/usr --enable-$t --disable-cgi --disable-phpdbg \ --with-config-file-path=/etc/php8/$t --with-config-file-scan-dir=/etc/php8/conf.d \ --libdir=/usr/lib/php --libexecdir=/usr/lib/php --datadir=/usr/share/php/8.2 \ --sysconfdir=/etc --localstatedir=/var --mandir=/usr/share/man \ --enable-debug --enable-address-sanitizer --disable-rpath --disable-static \ --enable-filter --with-openssl --enable-mbstring --enable-bcmath --enable-calendar \ --with-curl --enable-exif --enable-ftp --enable-gd --with-gettext --with-gmp \ --enable-intl --with-mysqli --enable-mysqlnd --enable-shmop --enable-soap \ --with-readline \ --with-avif --with-webp --with-jpeg --with-xpm \ --enable-sockets --enable-sysvmsg --enable-sysvsem --enable-sysvshm --with-zip \ --with-password-argon2=/usr --with-external-pcre --with-mhash=/usr --with-libxml \ --enable-session --with-sodium --with-zlib=/usr --with-zlib-dir=/usr \ --enable-pcntl --with-libedit=shared,/usr export CFLAGS='-g -fsanitize=address -shared-libasan -fno-sanitize-recover -DZEND_TRACK_ARENA_ALLOC' export CPPFLAGS='-g -fsanitize=address -shared-libasan -fno-sanitize-recover -DZEND_TRACK_ARENA_ALLOC' export CXXFLAGS='-g -fsanitize=address -shared-libasan -fno-sanitize-recover -DZEND_TRACK_ARENA_ALLOC' export LDFLAGS='-g -fsanitize=address -shared-libasan -Wl,-rpath=/usr/lib/llvm-16/lib/clang/16/lib/linux/' make -j100 make install done ``` ### PHP Version PHP 8.2.11 ### Operating System Ubuntu 22.04

« previous php.bugs (#245800) next »