[php-src] Issue #10888: SIGSEGV reported
| From: | HeenaBansal2009 | Date: | Mon, 20 Mar 2023 17:47:23 +0000 |
| Subject: | [php-src] Issue #10888: SIGSEGV reported | ||
| Groups: | php.bugs | ||
| Request: | Send a blank email to php-bugs+get-243941@lists.php.net to get a copy of this message | ||
Issue: https://github.com/php/php-src/issues/10888
Author: HeenaBansal2009
### Description
I am working to fix backward compatible of my application with PHP 5.*.
The following code gives SIGSEGV in PHP 5.4*, However I don't see any obvious reason to report
segfault:
`char *headers = emalloc(strlen(INI_STR("headers") + 1);
`
PS: When I try to print alone values like INI_STR("headers"). or
strlen(INI_STR("headers")) , I am getting right results without coredump.
BT looks like:
```
(gdb) bt
#0 0x00007f3f0823a7d7 in kill () from /lib64/libc.so.6
#1 0x0000000000c93a44 in zend_mm_panic (message=0x12b2e0d "zend_mm_heap corrupted") at
/usr/src/php/Zend/zend_alloc.c:92
#2 0x0000000000c98af2 in _zend_mm_alloc_int (heap=0x3215590, size=1, __zend_filename=0x7f3eff4f9f44
"/XXX.c", __zend_lineno=269,
__zend_orig_filename=0x12b2eb8 "/usr/src/php/Zend/zend_alloc.c",
__zend_orig_lineno=2539) at /usr/src/php/Zend/zend_alloc.c:2016
#3 0x0000000000c9ac48 in _emalloc (size=1, __zend_filename=0x7f3eff4f9f44 "XXX.c",
__zend_lineno=269, __zend_orig_filename=0x12b2eb8 "/usr/src/php/Zend/zend_alloc.c",
__zend_orig_lineno=2539) at /usr/src/php/Zend/zend_alloc.c:2425
#4 0x0000000000c9afaa in _safe_emalloc (nmemb=1, size=1, offset=0, __zend_filename=0x7f3eff4f9f44
"/XXX.c", __zend_lineno=269, __zend_orig_filename=0x0, __zend_orig_lineno=0)
at /usr/src/php/Zend/zend_alloc.c:2539
#5 0x0000000000c9b1f1 in _ecalloc (nmemb=1, size=1, __zend_filename=0x7f3eff4f9f44
"XXX.c", __zend_lineno=269, __zend_orig_filename=0x0, __zend_orig_lineno=0)
at /usr/src/php/Zend/zend_alloc.c:2566
#6 0x00007f3eff4ee91b in parse_headers () at XXX.c:269
#7 0x00007f3eff4f0f4b in zm_activate_xxx (type=1, module_number=37) at XXX.c:1048
#8 0x0000000000cfd100 in zend_activate_modules () at /usr/src/php/Zend/zend_API.c:2335
#9 0x0000000000c07f29 in php_request_startup () at /usr/src/php/main/main.c:1596
#10 0x0000000000dfe544 in do_cli (argc=64, argv=0x7ffceaaa1338) at
/usr/src/php/sapi/cli/php_cli.c:960
#11 0x0000000000e00020 in main (argc=64, argv=0x7ffceaaa1338) at
/usr/src/php/sapi/cli/php_cli.c:1365
```
Any help will be appreciated.
### PHP Version
PHP 5.4.45
### Operating System
Ubuntu