Skip to content

Commit da5e09a

Browse files
committed
Merge branch 'PHP-7.0' into PHP-7.1
2 parents af2de53 + bd75f9e commit da5e09a

File tree

4 files changed

+71
-17
lines changed

4 files changed

+71
-17
lines changed

.gdbinit

Lines changed: 26 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -29,24 +29,35 @@ document ____executor_globals
2929
end
3030

3131
define print_cvs
32-
____executor_globals
33-
set $p = $eg.current_execute_data.CVs
34-
set $c = $eg.current_execute_data.op_array.last_var
35-
set $v = $eg.current_execute_data.op_array.vars
36-
set $i = 0
32+
if $argc == 0
33+
____executor_globals
34+
set $cv_ex_ptr = $eg.current_execute_data
35+
else
36+
set $cv_ex_ptr = (zend_execute_data *)$arg0
37+
end
38+
set $cv_count = $cv_ex_ptr.func.op_array.last_var
39+
set $cv = $cv_ex_ptr.func.op_array.vars
40+
set $cv_idx = 0
41+
set $callFrameSize = (sizeof(zend_execute_data) + sizeof(zval) - 1) / sizeof(zval)
3742

38-
printf "Compiled variables count: %d\n", $c
39-
while $i < $c
40-
printf "%d = %s\n", $i, $v[$i].name
41-
if $p[$i] != 0
42-
printzv *$p[$i]
43-
else
44-
printf "*uninitialized*\n"
45-
end
46-
set $i = $i + 1
43+
printf "Compiled variables count: %d\n\n", $cv_count
44+
while $cv_idx < $cv_count
45+
printf "[%d] '%s'\n", $cv_idx, $cv[$cv_idx].val
46+
set $zvalue = ((zval *) $cv_ex_ptr) + $callFrameSize + $cv_idx
47+
printzv $zvalue
48+
set $cv_idx = $cv_idx + 1
4749
end
4850
end
4951

52+
document print_cvs
53+
Prints the compiled variables and their values.
54+
If a zend_execute_data pointer is set this will print the compiled
55+
variables of that scope. If no parameter is used it will use
56+
current_execute_data for scope.
57+
58+
usage: print_cvs [zend_execute_data *]
59+
end
60+
5061
define dump_bt
5162
set $ex = $arg0
5263
while $ex
@@ -563,7 +574,7 @@ end
563574

564575
document print_zstr
565576
print the length and contents of a zend string
566-
usage: print_zstr [ptr]
577+
usage: print_zstr <ptr>
567578
end
568579

569580
define zbacktrace

NEWS

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,10 @@ PHP NEWS
1111
- FCGI:
1212
. Fixed bug #73904 (php-cgi fails to load -c specified php.ini file). (Anatol)
1313

14+
- Mysqlnd:
15+
. Fixed bug #69899 (segfault on close() after free_result() with mysqlnd).
16+
(Richard Fussenegger)
17+
1418
- OpenSSL:
1519
. Fixed bug #71519 (add serial hex to return value array). (xrobau)
1620
. Fixed bug #73692 (Compile ext/openssl with openssl 1.1.0 on Win). (Anatol)

ext/mysqli/tests/bug69899.phpt

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
--TEST--
2+
Bug #69899: Segfault on stmt close after free_result with mysqlnd.
3+
--DESCRIPTION--
4+
The segfault happens only if the database connection was already closed and
5+
free_result is called on a prepared statement followed by closing that
6+
statement. This is due to mysqlnd_stmt::free_result (mysqlnd_ps.c) which
7+
unconditionally sets the connection of the statement to ready, despite the fact
8+
that it might already be closed.
9+
--SKIPIF--
10+
<?php
11+
require_once __DIR__ . '/skipif.inc';
12+
require_once __DIR__ . '/skipifconnectfailure.inc';
13+
require_once __DIR__ . '/connect.inc';
14+
if (!$IS_MYSQLND) {
15+
die('mysqlnd only');
16+
}
17+
?>
18+
--FILE--
19+
<?php
20+
21+
require_once __DIR__ . '/connect.inc';
22+
23+
mysqli_report(MYSQLI_REPORT_ERROR | MYSQLI_REPORT_STRICT);
24+
25+
$mysqli = new mysqli($host, $user, $passwd, $db, $port, $socket);
26+
$stmt = $mysqli->prepare('SELECT 1');
27+
28+
var_dump(
29+
$mysqli->close(),
30+
$stmt->free_result(),
31+
$stmt->close()
32+
);
33+
34+
?>
35+
--EXPECT--
36+
bool(true)
37+
NULL
38+
bool(true)

ext/mysqlnd/mysqlnd_ps.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2032,8 +2032,9 @@ MYSQLND_METHOD(mysqlnd_stmt, free_result)(MYSQLND_STMT * const s)
20322032
stmt->state = MYSQLND_STMT_PREPARED;
20332033
}
20342034

2035-
/* Line is free! */
2036-
SET_CONNECTION_STATE(&conn->state, CONN_READY);
2035+
if (GET_CONNECTION_STATE(&conn->state) != CONN_QUIT_SENT) {
2036+
SET_CONNECTION_STATE(&conn->state, CONN_READY);
2037+
}
20372038

20382039
DBG_RETURN(PASS);
20392040
}

0 commit comments

Comments
 (0)