-
-
Notifications
You must be signed in to change notification settings - Fork 95
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
Segfault when using references in thread #306
Comments
Hi @realFlowControl! Does this happen on any PHP version? |
So far this issue is in the |
Interestingly another way to workaround in case no OPcache is around is to declare the |
Smaller reproducer: <?php
$run = function() {
$a = [];
for ($i = 0; $i < 100; $i++) {
$b = &$a[$i];
}
return 0;
};
for ($i = 0; $i < 10; $i++) {
$futures[$i] = \parallel\run($run, []);
}
for ($i = 0; $i < 10; $i++) {
var_dump($futures[$i]->value());
} What is happening is that an array literal is copied to A refcount of 2 prevented this by forcing the VM to separate the array before modifying it. Reverting two lines here and here would fix the issue, but this is inconsistent with other code in copy.c. Changing this line to Edit: When OPcache is enabled, parallel relies on it to manage literals. In this case, literals have a refcount of 2. |
Running code that uses a reference to an element in an array in a thread segfaults with the following backtrace:
You can reproduce using https://github.com/realFlowControl/1brc/blob/main/calculateAverage.php, the
opline
points to line 71 (where the array is accessed). If I comment the entireif
-block, it segfaults in another line.It started with 32cd9c3 and the change that leads to this is this line:
parallel/src/copy.c
Line 191 in d8a0113
Setting this back to
2
will fix the segfault, but lead to ASAN tests failing ;-)I sadly have no idea what is going on :-(
Edit (2024-10-02): if OPcache is enabled, this works like a charm, without any issues. As soon as I disable OPcache, it crashes
The text was updated successfully, but these errors were encountered: