[php-src] Issue #10523: Segfault calling zend_throw_exception
| From: | pepone | Date: | Mon, 06 Feb 2023 21:15:05 +0000 |
| Subject: | [php-src] Issue #10523: Segfault calling zend_throw_exception | ||
| Groups: | php.bugs | ||
| Request: | Send a blank email to php-bugs+get-243661@lists.php.net to get a copy of this message | ||
Issue: https://github.com/php/php-src/issues/10523
Author: pepone
### Description
Hi,
Trying to update an extension from PHP 8.1 to PHP 8.2 I hitting this segfault when trying to
initialize an exception
```
#0 0x00005555558f7b23 in get_attribute_str (attributes=0x2, str=str@entry=0x5555562799a2
"sensitiveparameter", len=len@entry=18, offset=1) at
/home/jose/php-src/Zend/zend_attributes.c:159
#1 0x00005555558f7fec in zend_get_parameter_attribute_str (attributes=<optimized out>,
str=str@entry=0x5555562799a2 "sensitiveparameter", len=len@entry=18, offset=<optimized
out>) at /home/jose/php-src/Zend/zend_attributes.c:186
#2 0x00005555558f6bac in debug_backtrace_get_args (arg_array=0x7fffffff9c00, call=0x7ffff5616ce0)
at /home/jose/php-src/Zend/zend_builtin_functions.c:1636
#3 zend_fetch_debug_backtrace (return_value=return_value@entry=0x7fffffff9c90,
skip_last=skip_last@entry=0, options=0, limit=limit@entry=0) at
/home/jose/php-src/Zend/zend_builtin_functions.c:1852
#4 0x00005555559536e0 in zend_default_exception_new (class_type=0x55555673f1f0) at
/home/jose/php-src/Zend/zend_exceptions.c:255
#5 0x00005555558de57c in _object_and_properties_init (properties=0x0, class_type=0x55555673f1f0,
arg=0x7fffffff9d20) at /home/jose/php-src/Zend/zend_API.c:1722
#6 object_init_ex (arg=0x7fffffff9d20, class_type=0x55555673f1f0) at
/home/jose/php-src/Zend/zend_API.c:1736
#7 0x00007ffff4de98f0 in throwError (name=..., msg="invalid value for argument 1 in operation
`opByte'") at src/php/Util.cpp:757
#8 0x00007ffff4decf5d in IcePHP::invalidArgument (fmt=<optimized out>) at
src/php/Util.cpp:815
#9 0x00007ffff4dd4fbc in IcePHP::TypedInvocation::prepareRequest (params={...}, os=0x7fffffffa450,
args=0x7ffff56c59c0, argc=<optimized out>, this=0x555556829860) at src/php/Operation.cpp:471
#10 IcePHP::SyncTypedInvocation::invoke (this=0x555556829860, execute_data=0x7ffff5616ce0,
return_value=0x7fffffffa770) at src/php/Operation.cpp:743
#11 0x00007ffff4dd717e in zif_IcePHP_Operation_call (execute_data=0x7ffff5616ce0,
return_value=0x7fffffffa770) at src/php/Operation.cpp:878
#12 0x000055555594b14c in ZEND_DO_FCALL_SPEC_RETVAL_UNUSED_HANDLER () at
/home/jose/php-src/Zend/zend_vm_execute.h:1842
#13 execute_ex (ex=0x2) at /home/jose/php-src/Zend/zend_vm_execute.h:56591
#14 0x000055555594c6c0 in zend_execute (op_array=0x7ffff568f000, return_value=0x0) at
/home/jose/php-src/Zend/zend_vm_execute.h:60935
#15 0x00005555558daff6 in zend_execute_scripts (type=type@entry=8, retval=retval@entry=0x0,
file_count=file_count@entry=3) at /home/jose/php-src/Zend/zend.c:1845
#16 0x000055555587048a in php_execute_script (primary_file=primary_file@entry=0x7fffffffcd00) at
/home/jose/php-src/main/main.c:2481
#17 0x00005555559c0d8b in do_cli (argc=16, argv=0x555556633df0) at
/home/jose/php-src/sapi/cli/php_cli.c:964
#18 0x0000555555641bc3 in main (argc=16, argv=0x555556633df0) at
/home/jose/php-src/sapi/cli/php_cli.c:1333
(gdb) frame 0
#0 0x00005555558f7b23 in get_attribute_str (attributes=0x2, str=str@entry=0x5555562799a2
"sensitiveparameter", len=len@entry=18, offset=1) at
/home/jose/php-src/Zend/zend_attributes.c:159
159 ZEND_HASH_PACKED_FOREACH_PTR(attributes, attr) {
(gdb) frame 1
#1 0x00005555558f7fec in zend_get_parameter_attribute_str (attributes=<optimized out>,
str=str@entry=0x5555562799a2 "sensitiveparameter", len=len@entry=18, offset=<optimized
out>) at /home/jose/php-src/Zend/zend_attributes.c:186
186 return get_attribute_str(attributes, str, len, offset + 1);
```
My code is calling
object_init_ex to initialize InvalidArgumentException
instance.
https://github.com/zeroc-ice/ice/blob/bb38fdff50c925a3e3fe8a9abe869b2e3008d000/php/src/php/Util.cpp#L748-L760
Any idea what can be causing this segfault, the extension has been working fine up to php 8.1, but
we start seeing this when upgrading to 8.2.
### PHP Version
PHP 8.3.0-dev
### Operating System
Ubuntu 22.04