Memory leak with notices in pgsql

未关闭
#21,575 0 条评论 0 个 reaction 已指派 1 人 在 GitHub 查看

@devnexen 已经在做这个了。

开始于 2026年3月29日。

评估

这个 Issue 还没有评估数据。

描述

Bug Extension: pgsql Status: Needs Triage
Description

Found on the ppc64 runner, when it had a library upgrade that Postgres took some issue with that affected collation, which generated some messages on connection (which seem like the source of the leak).

========DIFF========
001+ WARNING:  database "test" has a collation version mismatch
002+ DETAIL:  The database was created using collation version 2.40, but the operating system provides version 2.42.
003+ HINT:  Rebuild all objects in this database that use the default collation and run ALTER DATABASE test REFRESH COLLATION VERSION, or build PostgreSQL with the right library version.
     bool(true)
     bool(true)
     bool(true)
     bool(false)
     bool(false)
     bool(false)
010+ 
011+ =================================================================
012+ ==94964==ERROR: LeakSanitizer: detected memory leaks
013+ 
014+ Direct leak of 112 byte(s) in 2 object(s) allocated from:
015+     #0 0x10ec492e0 in malloc (/srv/actions/.cache/act/6f82ab660bce2562/hostexecutor/sapi/cli/php+0x2e492e0)
016+     #1 0x1144f9b84 in tracked_malloc /srv/actions/.cache/act/6f82ab660bce2562/hostexecutor/Zend/zend_alloc.c:3017:14
017+     #2 0x114507548 in _emalloc /srv/actions/.cache/act/6f82ab660bce2562/hostexecutor/Zend/zend_alloc.c:2779:10
018+     #3 0x1152b5744 in _zend_new_array /srv/actions/.cache/act/6f82ab660bce2562/hostexecutor/Zend/zend_hash.c:290:18
019+     #4 0x111901984 in _php_pgsql_notice_handler /srv/actions/.cache/act/6f82ab660bce2562/hostexecutor/ext/pgsql/pgsql.c:336:19
020+     #5 0x3fff962dc27c  (/usr/lib64/postgresql-17/lib64/libpq.so.5+0xc27c)
021+     #6 0x3fff962f7bf0  (/usr/lib64/postgresql-17/lib64/libpq.so.5+0x27bf0)
022+     #7 0x3fff962f7fb8  (/usr/lib64/postgresql-17/lib64/libpq.so.5+0x27fb8)
023+     #8 0x3fff962ec388 in PQisBusy (/usr/lib64/postgresql-17/lib64/libpq.so.5+0x1c388)
024+     #9 0x3fff962e4c44 in PQconnectPoll (/usr/lib64/postgresql-17/lib64/libpq.so.5+0x14c44)
025+     #10 0x3fff962e70b0  (/usr/lib64/postgresql-17/lib64/libpq.so.5+0x170b0)
026+     #11 0x3fff962e7ab4 in PQreset (/usr/lib64/postgresql-17/lib64/libpq.so.5+0x17ab4)
027+     #12 0x111808de0 in php_pgsql_do_connect /srv/actions/.cache/act/6f82ab660bce2562/hostexecutor/ext/pgsql/pgsql.c:734:5
028+     #13 0x11180e758 in zif_pg_pconnect /srv/actions/.cache/act/6f82ab660bce2562/hostexecutor/ext/pgsql/pgsql.c:881:2
029+     #14 0x114ef09b4 in ZEND_DO_ICALL_SPEC_RETVAL_USED_HANDLER /srv/actions/.cache/act/6f82ab660bce2562/hostexecutor/Zend/zend_vm_execute.h:1384:2
030+     #15 0x114a20830 in execute_ex /srv/actions/.cache/act/6f82ab660bce2562/hostexecutor/Zend/zend_vm_execute.h:110069:12
031+     #16 0x114a235bc in zend_execute /srv/actions/.cache/act/6f82ab660bce2562/hostexecutor/Zend/zend_vm_execute.h:115487:2
032+     #17 0x115a325e0 in zend_execute_script /srv/actions/.cache/act/6f82ab660bce2562/hostexecutor/Zend/zend.c:1980:3
033+     #18 0x113c5c160 in php_execute_script_ex /srv/actions/.cache/act/6f82ab660bce2562/hostexecutor/main/main.c:2648:13
034+     #19 0x113c5d588 in php_execute_script /srv/actions/.cache/act/6f82ab660bce2562/hostexecutor/main/main.c:2688:9
035+     #20 0x115a4c728 in do_cli /srv/actions/.cache/act/6f82ab660bce2562/hostexecutor/sapi/cli/php_cli.c:949:5
036+     #21 0x115a459f0 in main /srv/actions/.cache/act/6f82ab660bce2562/hostexecutor/sapi/cli/php_cli.c:1360:18
037+     #22 0x3fff95c86e80  (/usr/lib64/libc.so.6+0x26e80)
038+     #23 0x3fff95c870e4 in __libc_start_main (/usr/lib64/libc.so.6+0x270e4)
039+ 
040+ Indirect leak of 768 byte(s) in 2 object(s) allocated from:
041+     #0 0x10ec492e0 in malloc (/srv/actions/.cache/act/6f82ab660bce2562/hostexecutor/sapi/cli/php+0x2e492e0)
042+     #1 0x1144f9b84 in tracked_malloc /srv/actions/.cache/act/6f82ab660bce2562/hostexecutor/Zend/zend_alloc.c:3017:14
043+     #2 0x114507548 in _emalloc /srv/actions/.cache/act/6f82ab660bce2562/hostexecutor/Zend/zend_alloc.c:2779:10
044+     #3 0x1118685fc in zend_string_alloc /srv/actions/.cache/act/6f82ab660bce2562/hostexecutor/Zend/zend_string.h:167:36
045+     #4 0x111818858 in zend_string_init /srv/actions/.cache/act/6f82ab660bce2562/hostexecutor/Zend/zend_string.h:189:21
046+     #5 0x11181e67c in _php_pgsql_trim_message /srv/actions/.cache/act/6f82ab660bce2562/hostexecutor/ext/pgsql/pgsql.c:288:9
047+     #6 0x111901a6c in _php_pgsql_notice_handler /srv/actions/.cache/act/6f82ab660bce2562/hostexecutor/ext/pgsql/pgsql.c:339:33
048+     #7 0x3fff962dc27c  (/usr/lib64/postgresql-17/lib64/libpq.so.5+0xc27c)
049+     #8 0x3fff962f7bf0  (/usr/lib64/postgresql-17/lib64/libpq.so.5+0x27bf0)
050+     #9 0x3fff962f7fb8  (/usr/lib64/postgresql-17/lib64/libpq.so.5+0x27fb8)
051+     #10 0x3fff962ec388 in PQisBusy (/usr/lib64/postgresql-17/lib64/libpq.so.5+0x1c388)
052+     #11 0x3fff962e4c44 in PQconnectPoll (/usr/lib64/postgresql-17/lib64/libpq.so.5+0x14c44)
053+     #12 0x3fff962e70b0  (/usr/lib64/postgresql-17/lib64/libpq.so.5+0x170b0)
054+     #13 0x3fff962e7ab4 in PQreset (/usr/lib64/postgresql-17/lib64/libpq.so.5+0x17ab4)
055+     #14 0x111808de0 in php_pgsql_do_connect /srv/actions/.cache/act/6f82ab660bce2562/hostexecutor/ext/pgsql/pgsql.c:734:5
056+     #15 0x11180e758 in zif_pg_pconnect /srv/actions/.cache/act/6f82ab660bce2562/hostexecutor/ext/pgsql/pgsql.c:881:2
057+     #16 0x114ef09b4 in ZEND_DO_ICALL_SPEC_RETVAL_USED_HANDLER /srv/actions/.cache/act/6f82ab660bce2562/hostexecutor/Zend/zend_vm_execute.h:1384:2
058+     #17 0x114a20830 in execute_ex /srv/actions/.cache/act/6f82ab660bce2562/hostexecutor/Zend/zend_vm_execute.h:110069:12
059+     #18 0x114a235bc in zend_execute /srv/actions/.cache/act/6f82ab660bce2562/hostexecutor/Zend/zend_vm_execute.h:115487:2
060+     #19 0x115a325e0 in zend_execute_script /srv/actions/.cache/act/6f82ab660bce2562/hostexecutor/Zend/zend.c:1980:3
061+     #20 0x113c5c160 in php_execute_script_ex /srv/actions/.cache/act/6f82ab660bce2562/hostexecutor/main/main.c:2648:13
062+     #21 0x113c5d588 in php_execute_script /srv/actions/.cache/act/6f82ab660bce2562/hostexecutor/main/main.c:2688:9
063+     #22 0x115a4c728 in do_cli /srv/actions/.cache/act/6f82ab660bce2562/hostexecutor/sapi/cli/php_cli.c:949:5
064+     #23 0x115a459f0 in main /srv/actions/.cache/act/6f82ab660bce2562/hostexecutor/sapi/cli/php_cli.c:1360:18
065+     #24 0x3fff95c86e80  (/usr/lib64/libc.so.6+0x26e80)
066+     #25 0x3fff95c870e4 in __libc_start_main (/usr/lib64/libc.so.6+0x270e4)
067+ 
068+ Indirect leak of 272 byte(s) in 2 object(s) allocated from:
069+     #0 0x10ec492e0 in malloc (/srv/actions/.cache/act/6f82ab660bce2562/hostexecutor/sapi/cli/php+0x2e492e0)
070+     #1 0x1144f9b84 in tracked_malloc /srv/actions/.cache/act/6f82ab660bce2562/hostexecutor/Zend/zend_alloc.c:3017:14
071+     #2 0x114507548 in _emalloc /srv/actions/.cache/act/6f82ab660bce2562/hostexecutor/Zend/zend_alloc.c:2779:10
072+     #3 0x1152b6ad0 in zend_hash_real_init_packed_ex /srv/actions/.cache/act/6f82ab660bce2562/hostexecutor/Zend/zend_hash.c:156:10
073+     #4 0x1152ead48 in _zend_hash_index_add_or_update_i /srv/actions/.cache/act/6f82ab660bce2562/hostexecutor/Zend/zend_hash.c:1168:4
074+     #5 0x1152e7b2c in zend_hash_next_index_insert /srv/actions/.cache/act/6f82ab660bce2562/hostexecutor/Zend/zend_hash.c:1242:9
075+     #6 0x1119024f8 in _php_pgsql_notice_handler /srv/actions/.cache/act/6f82ab660bce2562/hostexecutor/ext/pgsql/pgsql.c:345:2
076+     #7 0x3fff962dc27c  (/usr/lib64/postgresql-17/lib64/libpq.so.5+0xc27c)
077+     #8 0x3fff962f7bf0  (/usr/lib64/postgresql-17/lib64/libpq.so.5+0x27bf0)
078+     #9 0x3fff962f7fb8  (/usr/lib64/postgresql-17/lib64/libpq.so.5+0x27fb8)
079+     #10 0x3fff962ec388 in PQisBusy (/usr/lib64/postgresql-17/lib64/libpq.so.5+0x1c388)
080+     #11 0x3fff962e4c44 in PQconnectPoll (/usr/lib64/postgresql-17/lib64/libpq.so.5+0x14c44)
081+     #12 0x3fff962e70b0  (/usr/lib64/postgresql-17/lib64/libpq.so.5+0x170b0)
082+     #13 0x3fff962e7ab4 in PQreset (/usr/lib64/postgresql-17/lib64/libpq.so.5+0x17ab4)
083+     #14 0x111808de0 in php_pgsql_do_connect /srv/actions/.cache/act/6f82ab660bce2562/hostexecutor/ext/pgsql/pgsql.c:734:5
084+     #15 0x11180e758 in zif_pg_pconnect /srv/actions/.cache/act/6f82ab660bce2562/hostexecutor/ext/pgsql/pgsql.c:881:2
085+     #16 0x114ef09b4 in ZEND_DO_ICALL_SPEC_RETVAL_USED_HANDLER /srv/actions/.cache/act/6f82ab660bce2562/hostexecutor/Zend/zend_vm_execute.h:1384:2
086+     #17 0x114a20830 in execute_ex /srv/actions/.cache/act/6f82ab660bce2562/hostexecutor/Zend/zend_vm_execute.h:110069:12
087+     #18 0x114a235bc in zend_execute /srv/actions/.cache/act/6f82ab660bce2562/hostexecutor/Zend/zend_vm_execute.h:115487:2
088+     #19 0x115a325e0 in zend_execute_script /srv/actions/.cache/act/6f82ab660bce2562/hostexecutor/Zend/zend.c:1980:3
089+     #20 0x113c5c160 in php_execute_script_ex /srv/actions/.cache/act/6f82ab660bce2562/hostexecutor/main/main.c:2648:13
090+     #21 0x113c5d588 in php_execute_script /srv/actions/.cache/act/6f82ab660bce2562/hostexecutor/main/main.c:2688:9
091+     #22 0x115a4c728 in do_cli /srv/actions/.cache/act/6f82ab660bce2562/hostexecutor/sapi/cli/php_cli.c:949:5
092+     #23 0x115a459f0 in main /srv/actions/.cache/act/6f82ab660bce2562/hostexecutor/sapi/cli/php_cli.c:1360:18
093+     #24 0x3fff95c86e80  (/usr/lib64/libc.so.6+0x26e80)
094+     #25 0x3fff95c870e4 in __libc_start_main (/usr/lib64/libc.so.6+0x270e4)
095+ 
096+ SUMMARY: AddressSanitizer: 1152 byte(s) leaked in 6 allocation(s).
========DONE========
FAIL GH-13519 - PGSQL_CONNECT_FORCE_NEW with persistent connections. [ext/pgsql/tests/gh13519.phpt] 
PHP Version
PHP 8.6.0-dev (cli) (built: Mar 29 2026 14:28:18) (ZTS DEBUG)
Copyright (c) The PHP Group
Zend Engine v4.6.0-dev, Copyright (c) Zend Technologies
    with Zend OPcache v8.6.0-dev, Copyright (c), by Zend Technologies
Operating System

Gentoo/ppc64

主要语言
C
星标
40.4k
派生
8.2k
平均合并
2 天 15 小时
30 天内合并 PR
103

贡献指南

打开贡献指南

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

php/php-src 的其他 Issue

查看 php/php-src 的全部 Issue

相似的 Issue

更多 C Issue

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。