php / php/php-src

Mysql PDO heap corruption on Win10 x64 1909 (PHP x86 NTS)

未关闭
#9,143 20 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看

还没有人认领这个 Issue。

Bug Extension: pdo_mysql Status: Needs Triage
主要语言
C
星标
40.4k
派生
8.1k
平均合并
2 天 13 小时
30 天内合并 PR
96

描述

Description

The following code:

<?php
define('DB_DRIVER', 'mysql');
define('DB_HOST', 'localhost');
define('DB_PORT', 3306);
define('DB_USER', '[removed]');
define('DB_PASS', '[removed]');
define('DB_NAME', '[removed]');
define('DB_DSN' , DB_DRIVER.':dbname='.DB_NAME.';host='.DB_HOST.';port='.DB_PORT);
$params = array(
  PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION,
  PDO::ATTR_PERSISTENT => true,
  PDO::ATTR_EMULATE_PREPARES => false,
  PDO::MYSQL_ATTR_INIT_COMMAND => "SET SESSION sql_mode='', group_concat_max_len=32000, time_zone='+00:00'"
);
$params[PDO::ATTR_DEFAULT_FETCH_MODE] = PDO::FETCH_OBJ;
$handle = new PDO(DB_DSN, DB_USER, DB_PASS, $params);

Resulted in this output:
Random crashes with the following in Event Viewer:

Faulting application name: php-cgi.exe, version: 8.1.8.0, time stamp: 0x62c4c3bb
Faulting module name: ntdll.dll, version: 10.0.18362.719, time stamp: 0x832e7bce
Exception code: 0xc0000374
Fault offset: 0x000df95d
Faulting process id: 0x5458
Faulting application start time: 0x01d8a070256f66a2
Faulting application path: C:\Program Files (x86)\php81\php-cgi.exe
Faulting module path: C:\Windows\SYSTEM32\ntdll.dll
Report Id: a41ae7dc-55de-4152-b401-9553e23d1b5d
Faulting package full name: 
Faulting package-relative application ID: 

But I expected this output instead:

Successful database connection and no crashing.

Other notes:
This issue seems to be somewhat random, but I was able to get it to consistently crash if I kill the idle db connection via the sql command kill <id>;, then refresh the page. Using IIS 10 configured to hand-off the request to php via fastcgi. Database server attempting to connect to is on the same machine - Version: 10.4.12-MariaDB-log - Win10 x64. DebugDiag log attached (zipped due to file ext limitation on github).

php-cgi.exe_220725_131714_CrashHangAnalysis.zip

PHP Version

PHP 8.1.8 x86 NTS

Operating System

Windows 10 x64 1909

贡献指南

打开贡献指南

从这里开始

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

调研方向

首先使用持久连接复现 issue 中所示的 PDO 连接,然后终止空闲的 MariaDB 连接,并通过 IIS FastCGI 刷新。检查随附的 DebugDiag 日志以及 PDO MySQL 的连接和重连路径;当相同序列不再导致堆损坏崩溃时,即表示完成。

由索引模型根据 Issue 内容生成。

评估

技术栈
mariadb, mysql, php
领域
databases
Issue 类型
缺陷
难度
4/5
预计耗时
3-5 天
活跃度
停滞
描述清晰度
基本清楚
新手友好度
35/100

把新 issue 发到你的邮箱

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