From:             slangley at google dot com
Operating system: N/A
PHP version:      5.3.15
Package:          MySQL related
Bug Type:         Bug
Bug description:mysqlnd mysqlnd_conn_methods table is mot restored correctly 
with mutliple init

Description:
------------
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 =
      mysqlnd_conn_get_methods();

  memcpy(&original_conn_methods,
         current_conn_methods,
         sizeof(st_mysqlnd_conn_methods));

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

Start/Stop/Start the php modules

php_module_startup(...)
php_module_shutdown(...)
php_module_startup(...)

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



-- 
Edit bug report at https://bugs.php.net/bug.php?id=62730&edit=1
-- 
Try a snapshot (PHP 5.4):            
https://bugs.php.net/fix.php?id=62730&r=trysnapshot54
Try a snapshot (PHP 5.3):            
https://bugs.php.net/fix.php?id=62730&r=trysnapshot53
Try a snapshot (trunk):              
https://bugs.php.net/fix.php?id=62730&r=trysnapshottrunk
Fixed in SVN:                        
https://bugs.php.net/fix.php?id=62730&r=fixed
Fixed in SVN and need be documented: 
https://bugs.php.net/fix.php?id=62730&r=needdocs
Fixed in release:                    
https://bugs.php.net/fix.php?id=62730&r=alreadyfixed
Need backtrace:                      
https://bugs.php.net/fix.php?id=62730&r=needtrace
Need Reproduce Script:               
https://bugs.php.net/fix.php?id=62730&r=needscript
Try newer version:                   
https://bugs.php.net/fix.php?id=62730&r=oldversion
Not developer issue:                 
https://bugs.php.net/fix.php?id=62730&r=support
Expected behavior:                   
https://bugs.php.net/fix.php?id=62730&r=notwrong
Not enough info:                     
https://bugs.php.net/fix.php?id=62730&r=notenoughinfo
Submitted twice:                     
https://bugs.php.net/fix.php?id=62730&r=submittedtwice
register_globals:                    
https://bugs.php.net/fix.php?id=62730&r=globals
PHP 4 support discontinued:          
https://bugs.php.net/fix.php?id=62730&r=php4
Daylight Savings:                    https://bugs.php.net/fix.php?id=62730&r=dst
IIS Stability:                       
https://bugs.php.net/fix.php?id=62730&r=isapi
Install GNU Sed:                     
https://bugs.php.net/fix.php?id=62730&r=gnused
Floating point limitations:          
https://bugs.php.net/fix.php?id=62730&r=float
No Zend Extensions:                  
https://bugs.php.net/fix.php?id=62730&r=nozend
MySQL Configuration Error:           
https://bugs.php.net/fix.php?id=62730&r=mysqlcfg

Reply via email to