php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #77597 mysqli_fetch_field hangs scripts in PHP 7.3.2
Submitted: 2019-02-11 02:30 UTC Modified: 2019-02-21 12:24 UTC
Votes:1
Avg. Score:3.0 ± 0.0
Reproduced:0 of 0 (0.0%)
From: ryan dot brothers at gmail dot com Assigned: nikic (profile)
Status: Closed Package: MySQLi related
PHP Version: 7.3.2 OS: Linux
Private report: No CVE-ID: None
 [2019-02-11 02:30 UTC] ryan dot brothers at gmail dot com
Description:
------------
I am running into an issue with PHP 7.3.2 where calling mysqli_fetch_field hangs the script.  The same script in PHP 7.2.15 runs successfully.

It only occurs when calling store_result() with MYSQLI_STORE_RESULT_COPY_DATA

It could be related to bug #68548 that I submitted a few years ago, but something changed in PHP 7.3.2 that causes the call to hang completely now.

For the below test script, I'm using SQL:

DROP TABLE IF EXISTS a;
CREATE TABLE a (b int);
INSERT INTO a VALUES (1),(2),(3),(4),(5),(6),(7),(8),(9);


Test script:
---------------
<?php
$mysqli = new mysqli('localhost', 'test', 'test', 'test');

$mysqli->real_query("SELECT * FROM a");

$result = $mysqli->store_result(MYSQLI_STORE_RESULT_COPY_DATA);

$field = $result->fetch_field();


Expected result:
----------------
Script runs and instantly exits.


Actual result:
--------------
In PHP 7.3.2 with MYSQLI_STORE_RESULT_COPY_DATA, the script hangs.

In PHP 7.2.15 with MYSQLI_STORE_RESULT_COPY_DATA, the script runs and instantly exits.

In PHP 7.3.2 without MYSQLI_STORE_RESULT_COPY_DATA, the script runs and instantly exits.

In PHP 7.2.15 without MYSQLI_STORE_RESULT_COPY_DATA, the script runs and instantly exits.


Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2019-02-21 12:08 UTC] nikic@php.net
-Status: Open +Status: Verified
 [2019-02-21 12:08 UTC] nikic@php.net
From the debug trace, there's an infinite loop of php_mysqlnd_rowp_read_text_protocol_c calls:

<mysqlnd_conn_data::store_result (total=5397 own=237 in_calls=5160)
>mysqlnd_res::fetch_field
| info : We have decode the whole result set to be able to satisfy this meta request
| >mysqlnd_result_buffered_c::initialize_result_set_rest
| | >php_mysqlnd_rowp_read_text_protocol_c
| | | >php_mysqlnd_rowp_read_text_protocol_aux
| | | <php_mysqlnd_rowp_read_text_protocol_aux (total=0 own=0 in_calls=0)
| | <php_mysqlnd_rowp_read_text_protocol_c (total=38 own=38 in_calls=0)
| | >php_mysqlnd_rowp_read_text_protocol_c
| | | >php_mysqlnd_rowp_read_text_protocol_aux
| | | <php_mysqlnd_rowp_read_text_protocol_aux (total=0 own=0 in_calls=0)
| | <php_mysqlnd_rowp_read_text_protocol_c (total=37 own=37 in_calls=0)
...
 [2019-02-21 12:24 UTC] nikic@php.net
-Status: Verified +Status: Assigned -Assigned To: +Assigned To: nikic
 [2019-02-21 12:52 UTC] nikic@php.net
Automatic comment on behalf of nikita.ppv@gmail.com
Revision: http://git.php.net/?p=php-src.git;a=commit;h=934691fabba00b2cc36a7a0c93279d41f399c7ba
Log: Fixed bug #77597
 [2019-02-21 12:52 UTC] nikic@php.net
-Status: Assigned +Status: Closed
 
PHP Copyright © 2001-2019 The PHP Group
All rights reserved.
Last updated: Sat Apr 20 20:01:26 2019 UTC