Skip to content

Segmentation fault on script exit #9361

Closed
@dvaeversted

Description

@dvaeversted

Description

After updating from PHP 8.0.X to 8.1.9, we started experiencing segfaults on a memory heavy script.
We run it using the following command line:
php -d memory_limit=8192M cronscript.php

I was unable to construct a reproducer at this time, but no extensions are used, it is a script that reads in 3 different large files, does some calculations through a bunch of loops, and will crash with a segfault at the end of script execution (either on exit; or just when no more lines are left in the script).
We tested it on latest 8.2.0beta3, which exhibits the same problem, backtrace included as well.

From gdb i grabbed the following backtraces.

PHP 8.1.9:

Program received signal SIGSEGV, Segmentation fault.
0x00005555559825f8 in zend_set_memory_limit (memory_limit=8589934592) at /usr/src/debug/php-8.1.9/Zend/zend_alloc.c:2671
2671					heap->cached_chunks = p->next;
(gdb) bt
#0  0x00005555559825f8 in zend_set_memory_limit (memory_limit=8589934592) at /usr/src/debug/php-8.1.9/Zend/zend_alloc.c:2671
#1  0x00005555559465c0 in php_request_shutdown (dummy=dummy@entry=0x0) at /usr/src/debug/php-8.1.9/main/main.c:1879
#2  0x0000555555a8f2ae in do_cli (argc=4, argv=0x555555f75190) at /usr/src/debug/php-8.1.9/sapi/cli/php_cli.c:1135
#3  0x000055555578e2a5 in main (argc=4, argv=0x555555f75190) at /usr/src/debug/php-8.1.9/sapi/cli/php_cli.c:1367

PHP 8.2.0beta3:

Program received signal SIGSEGV, Segmentation fault.
0x00005555559929f8 in zend_set_memory_limit (memory_limit=8589934592) at /usr/src/debug/php-8.2.0beta3/Zend/zend_alloc.c:2692
2692					heap->cached_chunks = p->next;
Missing separate debuginfos, use: debuginfo-install gd3php-2.3.3-4.el7.remi.x86_64
(gdb) bt
#0  0x00005555559929f8 in zend_set_memory_limit (memory_limit=8589934592) at /usr/src/debug/php-8.2.0beta3/Zend/zend_alloc.c:2692
#1  0x0000555555956260 in php_request_shutdown (dummy=dummy@entry=0x0) at /usr/src/debug/php-8.2.0beta3/main/main.c:1890
#2  0x0000555555aa1e96 in do_cli (argc=4, argv=0x555555f75190) at /usr/src/debug/php-8.2.0beta3/sapi/cli/php_cli.c:1135
#3  0x000055555578f9bc in main (argc=4, argv=0x555555f75190) at /usr/src/debug/php-8.2.0beta3/sapi/cli/php_cli.c:1333

PHP Version

PHP 8.1.9

Operating System

Centos 7, AlmaLinux 8

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions