|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #63886 PHP crashes when quoting string with PDO and using mysqlnd_ms
Submitted: 2013-01-02 19:20 UTC Modified: 2013-02-04 17:48 UTC
Avg. Score:3.0 ± 0.0
Reproduced:0 of 0 (0.0%)
From: rubs33 at gmail dot com Assigned: mysql (profile)
Status: Closed Package: MySQL related
PHP Version: 5.5.0alpha2 OS: Fedora Linux 17 x86_64
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 !
Your email address:
Solve the problem:
28 - 18 = ?
Subscribe to this entry?

 [2013-01-02 19:20 UTC] rubs33 at gmail dot com
I am testing mysqlnd_ms plugin and I have just noticed that PHP crashes when I use PDO::quote method at these conditions:
1 - Enable mysqlnd_ms
2 - At PDO constructor call, specify a host to a replicated database and specify an invalid charset.

The plugin itself is working fine for its propose. The problem is with the "quote" method, that might been affected by the plugin.

PHP: 5.5.0alpha2
mysqlnd: 5.0.11-dev - 20120503
mysqlnd_ms: 1.4.2 (10402)
MySQL: 5.5.28

Note: when I run the test script with a non replicated database, I get the expected result and PHP did not crash.

Test script:
$pdo = new PDO('mysql:host=myapp;dbname=test;charset=x', 'rubens', '123');
$value = $pdo->quote('a');

Expected result:
string(3) "'a'"

Actual result:
Segmentation fault (core dumped)


Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2013-01-30 15:36 UTC]
-Package: mysqlnd_ms +Package: MySQL related -Assigned To: +Assigned To: mysql
 [2013-01-30 15:36 UTC]

this should be a follow up crash due to a mysqlnd bug. The connection is in an invalid state. You should not be allowed to connect at all.

Albeit the charset is invalid, you can connect if using mysqlnd:

bash: /home/nixnutz/git/superhero/php-srcphp: Datei oder Verzeichnis nicht gefunden
nixnutz@linux-0v4u:~/php-src/pecl/mysqlnd_ms/trunk> php -d mysqlnd.debug="d:t:O,/tmp/mysqlnd.trace" -r '$pdo = new PDO("mysql:host=;port=3307;dbname=test;charset=x"); var_dump($pdo->quote("a"));'
string(3) "'a'"

ixnutz@linux-0v4u:~/php-src/pecl/mysqlnd_ms/trunk> php -i | grep pdo
Configure Command =>  './configure'  '--with-mysql=mysqlnd' '--with-mysqli=mysqlnd' '--with-pdo-mysql=mysqlnd' '--enable-debug' '--disable-pear'
API Extensions => pdo_mysql,mysqli,mysql
pdo_mysql.debug => no value => no value
pdo_mysql.default_socket => /tmp/mysql.sock => /tmp/mysql.sock

However, if using libmysql one gets an error as I'd expect it:

nixnutz@linux-0v4u:~/php-src/pecl/mysqlnd_ms/trunk> /home/nixnutz/git/superhero/php-src/sapi/cli/php -d mysqlnd.debug="d:t:O,/tmp/mysqlnd.trace" -r '$pdo = new PDO("mysql:host=;port=3307;dbname=test;charset=x"); var_dump($pdo->quote("a"));'
Character set 'x' is not a compiled character set and is not specified in the '/home/nixnutz/ftp/mysql-5.6/install/share/charsets/Index.xml' file

Fatal error: Uncaught exception 'PDOException' with message 'SQLSTATE[HY000] [2019] Can't initialize character set x (path: /home/nixnutz/ftp/mysql-5.6/install/share/charsets/)' in Command line code:1
Stack trace:
#0 Command line code(1): PDO->__construct('mysql:host=127....')
#1 {main}
  thrown in Command line code on line 1
nixnutz@linux-0v4u:~/php-src/pecl/mysqlnd_ms/trunk>  /home/nixnutz/git/superhero/php-src/sapi/cli/php -i | grep pdo
Configure Command =>  './configure'  '--with-mysql=mysqlnd' '--with-mysqli=mysqlnd' '--with-pdo-mysql=/home/nixnutz/ftp/mysql-5.6/install/bin/mysql_config' '--enable-debug' '--disable-pear'
pdo_mysql.default_socket => /tmp/mysql.sock => /tmp/mysql.sock

I'd say: Andrey, please have a look...


PS: No mysqlnd package in select box?
 [2013-01-30 16:34 UTC]
Automatic comment from SVN on behalf of uw
Log: PDO and invalid charset bug 63886
 [2013-02-04 14:54 UTC]
-Status: Assigned +Status: Feedback
 [2013-02-04 14:54 UTC]
Please try using this snapshot:
For Windows:

Please try with updated PHP - from . The fix was just commited. The next snapshot should have it.
 [2013-02-04 17:41 UTC] rubs33 at gmail dot com
-Status: Feedback +Status: Assigned
 [2013-02-04 17:41 UTC] rubs33 at gmail dot com
It works for me.

When I try to connect to a database using an invalid charset, it throws a PDOException.

 [2013-02-04 17:48 UTC] rubs33 at gmail dot com
I think I was supposed to close this bug.
 [2013-02-04 17:48 UTC] rubs33 at gmail dot com
-Status: Assigned +Status: Closed
PHP Copyright © 2001-2022 The PHP Group
All rights reserved.
Last updated: Sat Jun 25 23:03:49 2022 UTC