Skip to content

fpm_env_init_main leaks environ #10611

Closed
Closed
@bwoebi

Description

@bwoebi

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

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions