-
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
Queue & Deque segfault upon GC #114
Comments
Backtrace:
|
I think you're absolutely right here. I'm assuming that the GC is stepping across the buffer but encounters an uninitialized The only solution I see here is to investigate how the buffer is allocated. Might be worth taking a look at how some of the SPL structures do this. It's also worth noting that Queue uses a Deque internally so fixing Deque's GC will fix Queue as well. |
Hm – upon further investigation, I can't (yet) recreate this on the official docker php image. I'll try to dig deeper to see if it's connected to another extension. |
I haven't encountered this myself, but I'll try to reproduce this locally today and see what happens. 👍 |
@orls keep in mind that unallocated memory is unpredictable, and this might only segfault sometimes. |
I have a feeling we're not clearing out on reallocation. Current: /**
* Reallocates a zval buffer to a specified length.
*/
#define REALLOC_ZVAL_BUFFER(ptr, n) \
do { \
ptr = erealloc(ptr, (n) * sizeof(zval)); \
} while (0) SPL uses See https://lxr.room11.org/xref/php-src%40master/ext/spl/spl_fixedarray.c#123 |
Indeed. Fiddling with extensions does seem to affect it, but I doubt that's related to the particular extensions involved, it'll just be happenstance of memory allocations over time. Here's the best recreation I can get, by restricting memory & allocating some stuff first. Using latest official php docker image (7.2.5)
|
This has now been fixed and released as 1.2.6 on PECL. |
Queue
&Deque
can segfault when GC is triggered:Observed on:
Not observed on php 7.1.4 & ds 1.2.3 (using this docker image mentioned in another issue).
I can avoid this locally by altering
php_ds_queue_get_gc
as follows (and similarlyphp_ds_dueue_get_gc
):...but I'm not confident that this is a proper fix, since the bug seems to indicate that the spare capacity in the buffer is mis-initialized. Perhaps something about the lower-level mem mgmt used by deque reallocation has changed in PHP?
The text was updated successfully, but these errors were encountered: