Segmentation fault by 006.phpt when make test
Description
Segmentation fault by 006.phpt when make test.
$ make test TESTS=ext/mailparse/
FAIL Check extract_part_file [ext/mailparse/tests/006.phpt]
006.out file
$ tail ext/mailparse/tests/006.out
hello, this is some text hello.
blah blah blah.
Extract part from string to output
hello, this is some text hello.
blah blah blah.
php: /home/ubuntu/src/php-src/Zend/zend_variables.c:63: zend_string_destroy: Assertion `(str)->val[(str)->len] == '\0' && "String is not null-terminated"' failed.
Aborted (core dumped)
Termsig=6
My environment
mailparse version is 3.1.6. PHP 8.2.9 on Ubuntu on multipass(M2 macOS).
$ sapi/cli/php -v
PHP 8.2.9 (cli) (built: Aug 28 2023 11:42:56) (NTS DEBUG)
Copyright (c) The PHP Group
Zend Engine v4.2.9, Copyright (c) Zend Technologies
Note: My PHP configure option is included --enable-debug.
$ sapi/cli/php -i | grep 'configure'
Configure Command => './configure' '--enable-debug' '--enable-mbstring' '--enable-mailparse' '--prefix=/home/ubuntu/php-8.2
Expected
No output SIGSEGV.
Sorry, but cannot reproduce with 8.2 or 8.3
Please provide full gdb backtrace
@remicollet Thanks for reply!
Please provide full gdb backtrace
Sorry, I can't reproduced on gdb on make test.
I put in php-src/ext to mailparse directory. The usual phpize command is not reproduced.
cd /path/to/php-src
git clone https://github.com/php/pecl-mail-mailparse ext/mailparse
./buildconf -f
./configure --enable-debug --enable-mbstring --enable-mailparse # Compile php-src
make
make test TESTS=ext/mailparse
tail ext/mailparse/tests/006.out
I tried dump file from gdb backtrace.
(gdb) bt
#0 __pthread_kill_implementation (threadid=281473317905920, signo=signo@entry=6, no_tid=no_tid@entry=0) at ./nptl/pthread_kill.c:44
#1 0x0000ffff9cc4f254 in __pthread_kill_internal (signo=6, threadid=<optimized out>) at ./nptl/pthread_kill.c:78
#2 0x0000ffff9cc0a67c in __GI_raise (sig=sig@entry=6) at ../sysdeps/posix/raise.c:26
#3 0x0000ffff9cbf7130 in __GI_abort () at ./stdlib/abort.c:79
#4 0x0000ffff9cc03fd0 in __assert_fail_base (fmt=0xffff9cd1d3f8 "%s%s%s:%u: %s%sAssertion `%s' failed.\n%n",
assertion=assertion@entry=0xaaaae14c6ed8 "(str)->val[(str)->len] == '\\0' && \"String is not null-terminated\"",
file=file@entry=0xaaaae14c6e80 "/home/ubuntu/src/php-src/Zend/zend_variables.c", line=line@entry=63,
function=function@entry=0xaaaae14c7120 <__PRETTY_FUNCTION__.6> "zend_string_destroy") at ./assert/assert.c:92
#5 0x0000ffff9cc04040 in __GI___assert_fail (
assertion=0xaaaae14c6ed8 "(str)->val[(str)->len] == '\\0' && \"String is not null-terminated\"",
file=0xaaaae14c6e80 "/home/ubuntu/src/php-src/Zend/zend_variables.c", line=63,
function=0xaaaae14c7120 <__PRETTY_FUNCTION__.6> "zend_string_destroy") at ./assert/assert.c:101
#6 0x0000aaaae0a878d4 in zend_string_destroy (str=0xffff9a802620) at /home/ubuntu/src/php-src/Zend/zend_variables.c:63
#7 0x0000aaaae0a87880 in rc_dtor_func (p=0xffff9a802620) at /home/ubuntu/src/php-src/Zend/zend_variables.c:57
#8 0x0000aaaae0a877f8 in i_zval_ptr_dtor (zval_ptr=0xffffc43b0858) at /home/ubuntu/src/php-src/Zend/zend_variables.h:44
#9 0x0000aaaae0a87a34 in zval_ptr_dtor (zval_ptr=0xffffc43b0858) at /home/ubuntu/src/php-src/Zend/zend_variables.c:84
#10 0x0000aaaae0aaa368 in _zend_hash_del_el_ex (ht=0xaaaae168d608 <executor_globals+304>, idx=10, p=0xffff9a85e340, prev=0x0)
at /home/ubuntu/src/php-src/Zend/zend_hash.c:1420
#11 0x0000aaaae0aaa490 in _zend_hash_del_el (ht=0xaaaae168d608 <executor_globals+304>, idx=10, p=0xffff9a85e340)
at /home/ubuntu/src/php-src/Zend/zend_hash.c:1447
#12 0x0000aaaae0aac19c in zend_hash_graceful_reverse_destroy (ht=0xaaaae168d608 <executor_globals+304>)
at /home/ubuntu/src/php-src/Zend/zend_hash.c:1972
#13 0x0000aaaae0a6e2f8 in zend_shutdown_executor_values (fast_shutdown=false) at /home/ubuntu/src/php-src/Zend/zend_execute_API.c:284
#14 0x0000aaaae0a6edc8 in shutdown_executor () at /home/ubuntu/src/php-src/Zend/zend_execute_API.c:416
#15 0x0000aaaae0a8ad48 in zend_deactivate () at /home/ubuntu/src/php-src/Zend/zend.c:1259
#16 0x0000aaaae09d732c in php_request_shutdown (dummy=0x0) at /home/ubuntu/src/php-src/main/main.c:1863
#17 0x0000aaaae0c2ec58 in do_cli (argc=78, argv=0xaaab0a1e8300) at /home/ubuntu/src/php-src/sapi/cli/php_cli.c:1135
#18 0x0000aaaae0c2f10c in main (argc=78, argv=0xaaab0a1e8300) at /home/ubuntu/src/php-src/sapi/cli/php_cli.c:1333
#5 0x0000ffff9cc04040 in __GI___assert_fail ( assertion=0xaaaae14c6ed8 "(str)->val[(str)->len] == '\\0' && \"String is not null-terminated\"", file=0xaaaae14c6e80 "/home/ubuntu/src/php-src/Zend/zend_variables.c", line=63,
Not good.
See https://github.com/php/php-src/issues/15628.
This issue has been fixed upstream, so I'm closing this ticket.