Bug #77289 [Csd]: PDO MySQL segfaults with persistent connection

From: Date: Wed, 09 Jan 2019 08:52:33 +0000
Subject: Bug #77289 [Csd]: PDO MySQL segfaults with persistent connection
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-218858@lists.php.net to get a copy of this message
Edit report at https://bugs.php.net/bug.php?id=77289&edit=1

 ID:                 77289
 Updated by:         nikic@php.net
 Reported by:        bugs dot php dot net at mundpropaganda dot net
 Summary:            PDO MySQL segfaults with persistent connection
 Status:             Closed
 Type:               Bug
 Package:            PDO MySQL
 Operating System:   Linux 4.14.82
 PHP Version:        7.3.0
 Assigned To:        nikic
 Block user comment: N
 Private report:     N

 New Comment:

@lauri: Nice, I wasn't aware that PDO already had a handler we can use for this. I've
merged your patch.


Previous Comments:
------------------------------------------------------------------------
[2019-01-09 08:51:40] nikic@php.net

Automatic comment on behalf of lauri.kentta@gmail.com
Revision: http://git.php.net/?p=php-src.git;a=commit;h=63c38c9e4907b2d12885db7943b7053efe0d6c60
Log: Fixed bug #77289

------------------------------------------------------------------------
[2019-01-08 15:19:10] lauri dot kentta at gmail dot com

@nikic, thanks for pointing out those functions. That's exactly what I was looking for.
I'll send another patch to use them in pdo_mysql. It works and seems like the right solution.

By the way, both functions are used in mysqli as well.

------------------------------------------------------------------------
[2019-01-08 11:09:55] nikic@php.net

I think the problem is that the mysqlnd connection has end_psession and restart_psession handlers
that are supposed to be called at the end/start of a request respectively. If end_psession were
called, it would free the last_message and NULL it.

However, it seems that mysqli only calls restart_psession (which also nulls last_message, so
probably prevents the worst) and PDO doesn't call either (resulting in what we see here).

@dmitry: What do you think about this? I think reverting to use persistent flag for last_message is
probably the most pragmatic thing to do here. (There might be ABI concerns though...)

------------------------------------------------------------------------
[2019-01-08 09:37:38] nikic@php.net

last_message was changed in https://github.com/php/php-src/commit/a7305eb539596e175bd6c3ae9a20953358c5d677
to be allocated by Zend MM, with the comment that it's not supposed to be used in the next
request. I'm not sure if the attached patch is right, or if some use of last_message (or lack
of reset somewhere) is at fault here.

------------------------------------------------------------------------
[2019-01-07 19:29:04] lauri dot kentta at gmail dot com

Related To: Bug #77312

------------------------------------------------------------------------


The remainder of the comments for this report are too long. To view
the rest of the comments, please view the bug report online at

    https://bugs.php.net/bug.php?id=77289


--
Edit this bug report at https://bugs.php.net/bug.php?id=77289&edit=1


Thread (13 messages)

« previous php.bugs (#218858) next »