Skip to content

Using ArrayObject with ARRAY_AS_PROPS and by reference assignment #18403

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
andrew-demb opened this issue Apr 23, 2025 · 5 comments
Closed

Using ArrayObject with ARRAY_AS_PROPS and by reference assignment #18403

andrew-demb opened this issue Apr 23, 2025 · 5 comments

Comments

@andrew-demb
Copy link
Contributor

Description

Reproducible in PHP 8.3.20. Cannot be reproduced in PHP 8.3.19

The following code:

<?php

$object = new \ArrayObject([], \ArrayObject::ARRAY_AS_PROPS);
$foo = 'websocket';
$object->{$foo} = new \ArrayObject([], \ArrayObject::ARRAY_AS_PROPS);
$object = &$object->{$foo};

echo 'success';

Resulted in this output:

Process finished with exit code 139 (interrupted by signal 11:SIGSEGV)

But I expected this output instead:

success

https://3v4l.org/5qSOS

PHP Version

PHP 8.3.20 (cli) (built: Apr 14 2025 18:44:45) (NTS)
Copyright (c) The PHP Group
Zend Engine v4.3.20, Copyright (c) Zend Technologies
with Zend OPcache v8.3.20, Copyright (c), by Zend Technologies
with Xdebug v3.4.2, Copyright (c) 2002-2025, by Derick Rethans

Operating System

Debian 11

@andrew-demb
Copy link
Contributor Author

Refs: vanodevium/toml#4

@andrew-demb
Copy link
Contributor Author

Here's the output of gdb

(gdb) run test.php
Starting program: /usr/bin/php test.php
[Thread debugging using libthread_db enabled]
Using host libthread_db library "/lib/x86_64-linux-gnu/libthread_db.so.1".

Program received signal SIGSEGV, Segmentation fault.
spl_array_get_property_ptr_ptr (object=0x7ffff55facd8, name=0x7ffff555d500, type=1, cache_slot=0x0) at ./ext/spl/spl_array.c:849
849     ./ext/spl/spl_array.c: No such file or directory.

@andrew-demb
Copy link
Contributor Author

@Girgias
Copy link
Member

Girgias commented Apr 23, 2025

@nielsdos can you have a look?

@nielsdos
Copy link
Member

Sorry for the trouble, this is already fixed for the upcoming 8.3.21 release.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants