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

fpm_env_init_main leaks environ #10611

Closed
bwoebi opened this issue Feb 17, 2023 · 0 comments
Closed

fpm_env_init_main leaks environ #10611

bwoebi opened this issue Feb 17, 2023 · 0 comments

Comments

@bwoebi
Copy link
Member

bwoebi commented Feb 17, 2023

Description

Running fpm under LSAN gives

[17-Feb-2023 12:58:27] WARNING: [pool www] child 146 said into stderr: "================================================================="
[17-Feb-2023 12:58:27] WARNING: [pool www] child 146 said into stderr: "==146==ERROR: LeakSanitizer: detected memory leaks"
[17-Feb-2023 12:58:27] WARNING: [pool www] child 146 said into stderr: "Direct leak of 208 byte(s) in 1 object(s) allocated from:"
[17-Feb-2023 12:58:27] WARNING: [pool www] child 146 said into stderr: "    #0 0xffffb0c7643b in malloc (/usr/lib/aarch64-linux-gnu/libasan.so.5+0xcf43b)"
[17-Feb-2023 12:58:27] WARNING: [pool www] child 146 said into stderr: "    #1 0xaaaae5d06caf in fpm_env_init_main /usr/local/src/php/sapi/fpm/fpm/fpm_env.c:258"
[17-Feb-2023 12:58:27] WARNING: [pool www] child 146 said into stderr: "    #2 0xaaaae5cf1143 in fpm_init /usr/local/src/php/sapi/fpm/fpm/fpm.c:62"
[17-Feb-2023 12:58:27] WARNING: [pool www] child 146 said into stderr: "    #3 0xaaaae5d16fcb in main /usr/local/src/php/sapi/fpm/fpm/fpm_main.c:1803"
[17-Feb-2023 12:58:27] WARNING: [pool www] child 146 said into stderr: "    #4 0xffffafff1da3 in __libc_start_main ../csu/libc-start.c:308"
[17-Feb-2023 12:58:27] WARNING: [pool www] child 146 said into stderr: "    #5 0xaaaae47ba193  (/opt/php/debug-zts-asan/sbin/php-fpm+0x4ca193)"
[17-Feb-2023 12:58:27] WARNING: [pool www] child 146 said into stderr: "Indirect leak of 48 byte(s) in 2 object(s) allocated from:"
[17-Feb-2023 12:58:27] WARNING: [pool www] child 146 said into stderr: "    #0 0xffffb0be14f7 in strdup (/usr/lib/aarch64-linux-gnu/libasan.so.5+0x3a4f7)"
[17-Feb-2023 12:58:27] WARNING: [pool www] child 146 said into stderr: "    #1 0xaaaae5d06d93 in fpm_env_init_main /usr/local/src/php/sapi/fpm/fpm/fpm_env.c:264"
[17-Feb-2023 12:58:27] WARNING: [pool www] child 146 said into stderr: "    #2 0xaaaae5cf1143 in fpm_init /usr/local/src/php/sapi/fpm/fpm/fpm.c:62"
[17-Feb-2023 12:58:27] WARNING: [pool www] child 146 said into stderr: "    #3 0xaaaae5d16fcb in main /usr/local/src/php/sapi/fpm/fpm/fpm_main.c:1803"
[17-Feb-2023 12:58:27] WARNING: [pool www] child 146 said into stderr: "    #4 0xffffafff1da3 in __libc_start_main ../csu/libc-start.c:308"
[17-Feb-2023 12:58:27] WARNING: [pool www] child 146 said into stderr: "    #5 0xaaaae47ba193  (/opt/php/debug-zts-asan/sbin/php-fpm+0x4ca193)"
[17-Feb-2023 12:58:27] WARNING: [pool www] child 146 said into stderr: "SUMMARY: AddressSanitizer: 256 byte(s) leaked in 3 allocation(s)."

Which is caused on Linux by the fact that the environ copy created in fpm_env_init_main() is never freed.

PHP Version

PHP 8.1+

Operating System

Linux

nielsdos added a commit to nielsdos/php-src that referenced this issue Feb 18, 2023
nielsdos added a commit to nielsdos/php-src that referenced this issue Feb 18, 2023
nielsdos added a commit to nielsdos/php-src that referenced this issue Mar 11, 2023
nielsdos added a commit that referenced this issue Mar 11, 2023
* PHP-8.1:
  Fix GH-10611: fpm_env_init_main leaks environ
nielsdos added a commit that referenced this issue Mar 11, 2023
* PHP-8.2:
  Fix GH-10611: fpm_env_init_main leaks environ
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants
@bwoebi and others