FPM: Freeing child allocated data
Nobody has claimed this yet.
- Dominant language
- C
- Stars
- 40.4k
- Forks
- 8.1k
- Avg merge
- 2d 13h
- Merged PRs (30d)
- 96
Description
Description
FPM allocates some data during child initialization for keeping around some configuration options. This is done in following places:
- https://github.com/php/php-src/blob/15184435007ae13d31902be2613632b813b80b0f/sapi/fpm/fpm/fpm_log.c#L81 (this was reported in https://bugs.php.net/bug.php?id=75635 and it is the reason for creating this issue).
- https://github.com/php/php-src/blob/15184435007ae13d31902be2613632b813b80b0f/sapi/fpm/fpm/fpm_log.c#L91
- https://github.com/php/php-src/blob/15184435007ae13d31902be2613632b813b80b0f/sapi/fpm/fpm/fpm_status.c#L32
- https://github.com/php/php-src/blob/15184435007ae13d31902be2613632b813b80b0f/sapi/fpm/fpm/fpm_status.c#L40-L41
- https://github.com/php/php-src/blob/15184435007ae13d31902be2613632b813b80b0f/sapi/fpm/fpm/fpm_php.c#L219-L221 (this just takes ownership but means the same sort of leak effectively)
Those values are never freed. They are needed for the whole life of child so it is not a big issue as it gets released on process exit (that's why this is classified more as a feature and not a bug because there is no impact of this). However it is a good convention to free those values so some child destroy functions should be created for that purpose and called before exiting the child.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by reading the child-initialization code in sapi/fpm/fpm/fpm_log.c, fpm_status.c, and fpm_php.c, then trace the child exit path. Add corresponding child-destroy handling for the allocations listed in the issue and call it before the child exits. Done means those child-owned values are freed during shutdown rather than only at process exit.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- c, php
- Domain
- backend
- Issue type
- Feature
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 42/100