Skip to content

Fix GC buffer unnecessarily growing up to GC_MAX_BUF_SIZE when scanning WeakMaps - #13572

Closed
arnaud-lb wants to merge 1 commit into
php:PHP-8.3from
arnaud-lb:gh13569
Closed

arnaud-lb wants to merge 1 commit into
php:PHP-8.3from
arnaud-lb:gh13569

Conversation

@arnaud-lb

@arnaud-lb arnaud-lb commented Mar 2, 2024 •

Copy link
Copy Markdown
Member

This should fix #13569.

This is caused by a wrong condition in gc_extra_root() causing it to grow the root buffer when it's not necessary: It grows the buffer when the first_unused slot is higher or equal to gc_threshold. Additionally, this condition applies repeatedly because the threshold is (legitimately) not updated in this case, thus the buffer size quickly grows towards GC_MAX_BUF_SIZE, after which an E_WARNING is triggered and the GC is disabled.

The fix is to compare first_unused to buf_size instead.

@arnaud-lb arnaud-lb changed the title Fix GC buffer unnecessarily grows up to GC_MAX_BUF_SIZE when scanning WeakMaps Fix GC buffer unnecessarily growing up to GC_MAX_BUF_SIZE when scanning WeakMaps Mar 2, 2024
@arnaud-lb
arnaud-lb marked this pull request as ready for review March 4, 2024 12:54
@arnaud-lb
arnaud-lb changed the base branch from master to PHP-8.3 March 4, 2024 12:59
@arnaud-lb

Copy link
Copy Markdown
Member Author

Merged 6b57e2d

@arnaud-lb arnaud-lb closed this Mar 5, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

New Garbage Collector feature for WeakMap added in 8.3 #10932 causes GC buffer overflow which then causes segfault

2 participants