[php-src] Issue #10611: fpm_env_init_main leaks environ

From: Date: Fri, 17 Feb 2023 14:08:04 +0000
Subject: [php-src] Issue #10611: fpm_env_init_main leaks environ
Groups: php.bugs 
Request: Send a blank email to php-bugs+get-243744@lists.php.net to get a copy of this message
Issue: https://github.com/php/php-src/issues/10611
Author: 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


Thread (1 message)

  • bwoebi
« previous php.bugs (#243744) next »