|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #62730 mysqlnd mysqlnd_conn_methods table is mot restored correctly with mutliple init
Submitted: 2012-08-03 00:45 UTC Modified: 2014-12-30 10:41 UTC
From: slangley at google dot com Assigned:
Status: No Feedback Package: MySQL related
PHP Version: 5.3.15 OS: N/A
Private report: No CVE-ID: None
View Add Comment Developer Edit
Anyone can comment on a bug. Have a simpler test case? Does it work for you on a different platform? Let us know!
Just going to say 'Me too!'? Don't clutter the database with that please — but make sure to vote on the bug!
Your email address:
Solve the problem:
44 + 2 = ?
Subscribe to this entry?

 [2012-08-03 00:45 UTC] slangley at google dot com
If a plugin alters the connection methods table, then the original connection 
table is not restored if there is a php_module_shutdown()/php_module_init() cycle 
in the same process.

This is because mysqlnd_conn_methods is a pointer to 
MYSQLND_CLASS_METHOD_TABLE_NAME(mysqlnd_conn), sizeof(mysqlnd_conn_methods)) so 
changing the values in mysqlnd_conn_methods actually changes the values in the 
master table.

To fix, mysqlnd_conn_methods should take a copy of the table on init.

Test script:
Create a plugin that replaces the conenct function with a function that simply flows the call to the original callback.

static enum_func_status
MYSQLND_METHOD(my_test_plugin, query)(MYSQLND* conn,
    const char* query, unsigned int query_len TSRMLS_DC) {
  return original_conn_methods.query(conn, query, query_len);

Register this plugin during MINIT

  struct st_mysqlnd_conn_methods* current_conn_methods =


  current_conn_methods->connect = MYSQLND_METHOD(speckle_mysqlnd_conn, connect);

Start/Stop/Start the php modules


Try and connect to the mysqldb - you'll get a stack overflow.


Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2013-03-08 15:08 UTC]
It was never meant to restore the tables after mshutdown because after that the SAPI usually closes the process. Which SAPI do you use? Embedded?
 [2013-03-09 21:53 UTC] slangley at google dot com
For whatever reason I can't use "edit" as it wont accept my password - ho hum.


We have our own SAPI.

FWIW I don't think this is an issue anymore on 5.4+ so you can close this bug.
 [2013-03-11 08:40 UTC]
5.4 has different architecture - fixed
 [2014-02-26 10:19 UTC]
-Status: Open +Status: Feedback
 [2014-02-26 10:19 UTC]
According to Andrey its fixed since 2013, is it? Setting to Feedback...
 [2014-12-30 10:41 UTC] php-bugs at lists dot php dot net
No feedback was provided. The bug is being suspended because
we assume that you are no longer experiencing the problem.
If this is not the case and you are able to provide the
information that was requested earlier, please do so and
change the status of the bug back to "Re-Opened". Thank you.
PHP Copyright © 2001-2023 The PHP Group
All rights reserved.
Last updated: Thu Nov 30 20:01:26 2023 UTC