Timer leaks on pcntl_fork in ZTS build
オープン
まだ誰も着手していません。
Bug
Extension: pcntl
Status: Needs Triage
- 主要言語
- C
- スター
- 40.4k
- フォーク
- 8.1k
- 平均マージ
- 2日 13時間
- マージ済み PR(30日)
- 96
説明
Description
The following code:
<?php
pcntl_fork();
Resulted in this output (in child process):
=================================================================
==58097==ERROR: LeakSanitizer: detected memory leaks
Direct leak of 8 byte(s) in 1 object(s) allocated from:
#0 0xffffa37f943b in malloc (/usr/lib/aarch64-linux-gnu/libasan.so.5+0xcf43b)
#1 0xffffa3622aaf in timer_create ../sysdeps/unix/sysv/linux/timer_create.c:59
#2 0xaaaacd663a6b in zend_max_execution_timer_init /usr/local/src/php/Zend/zend_max_execution_timer.c:46
#3 0xaaaacd2913c7 in init_executor /usr/local/src/php/Zend/zend_execute_API.c:202
#4 0xaaaacd2e3497 in zend_activate /usr/local/src/php/Zend/zend.c:1257
#5 0xaaaacd0b09c3 in php_request_startup /usr/local/src/php/main/main.c:1758
#6 0xaaaacd7b92db in do_cli /usr/local/src/php/sapi/cli/php_cli.c:934
#7 0xaaaacd7bbd57 in main /usr/local/src/php/sapi/cli/php_cli.c:1340
#8 0xffffa08c7da3 in __libc_start_main ../csu/libc-start.c:308
#9 0xaaaacbea50f3 (/opt/php/debug-zts-asan/bin/php+0x5b50f3)
There's an explicit comment that this shouldn't be freed after a fork:
void zend_max_execution_timer_shutdown(void) /* {{{ */
{
/* Don't try to delete a timer created before a call to fork() */
if (EG(pid) != getpid()) {
return;
}
So paging @dunglas who wrote that comment.
PHP Version
PHP 8.3
Operating System
No response
コントリビューションガイド
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
調査の方向性
AddressSanitizer 上で pcntl_fork を使用して PHP 8.3 ZTS のケースを再現し、その後、レポートに示されている初期化およびシャットダウンのパスと併せて zend_max_execution_timer.c を読みます。子プロセスのリークトレースを基準として使用します。親プロセスのタイマー処理を後退させることなく、reproducer がリークしたタイマーを報告しなくなれば完了です。
索引モデルが issue の本文から書いたものです。
評価
- 技術スタック
- c, php
- 領域
- backend, operating-systems
- issue の種類
- バグ
- 難易度
- 4/5
- 見積もり時間
- 3〜5日
- 活発さ
- 停滞
- 明瞭さ
- おおむね明確
- 初心者へのやさしさ
- 42/100