Skip to content
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

Multidimensional array writes don't work on ThreadSafeArray when the target sub-array doesn't exist #44

Open
dktapps opened this issue Feb 18, 2021 · 1 comment

Comments

@dktapps
Copy link
Member

dktapps commented Feb 18, 2021

<?php

declare(strict_types=1);

$t = [];
$t[0][0] = 1;
$t[0][1] = 2;

var_dump($t);

produces

array(1) {
  [0]=>
  array(2) {
    [0]=>
    int(1)
    [1]=>
    int(2)
  }
}

vs

<?php

declare(strict_types=1);

$t = new \Threaded();
$t[0][0] = 1;
$t[0][1] = 2;

var_dump($t);

which produces

Notice: Indirect modification of overloaded element of Threaded has no effect in C:\Users\dylan-work\Documents\projects\pocketmine-mp\test2.php on line 25

Notice: Indirect modification of overloaded element of Threaded has no effect in C:\Users\dylan-work\Documents\projects\pocketmine-mp\test2.php on line 26
object(Threaded)#1 (0) {
}
@dktapps
Copy link
Member Author

dktapps commented Feb 20, 2021

Seems like the real bug is that this check is not firing, because the offset doesn't exist: https://github.com/pmmp/pthreads/blob/fork/src/store.c#L311

On closer inspection this problem could be hard to solve, because BP_VAR_W writes could also be generated by something like threaded->nonExisting[0] = 1, which should not result in automatic property creation. pthreads_store_read() doesn't make any differentiation between property reads and array offset accesses.

@dktapps dktapps changed the title Multidimensional array writes don't work on Threaded when the target sub-array doesn't exist Multidimensional array writes don't work on ThreadSafeArray when the target sub-array doesn't exist May 16, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant