From:             andres at phalconphp dot com
Operating system: Linux/Mac
PHP version:      5.3Git-2012-06-09 (snap)
Package:          MySQLi related
Bug Type:         Bug
Bug description:Segmentation Fault in Mysqli/Mysqlnd

Description:
------------
Hi, i'm getting a segmentation fault when executing this code:

<?php

$link = mysqli_connect("127.0.0.1", "root", "", "test");

mysqli_real_escape_string($link, "1");

Result:

Mac (Snow leopard):

[#] php a.php 
Segmentation fault

[#] php -v
PHP 5.3.12 (cli) (built: Jun  4 2012 19:51:42) 
Copyright (c) 1997-2012 The PHP Group
Zend Engine v2.3.0, Copyright (c) 1998-2012 Zend Technologies

Ubuntu (11.10):
$ php a.php 
Segmentation fault

$ php -v
PHP 5.3.15-dev (cli) (built: Jun  8 2012 22:17:40) 
Copyright (c) 1997-2012 The PHP Group
Zend Engine v2.3.0, Copyright (c) 1998-2012 Zend Technologies



Test script:
---------------
This produces the segmentation fault:

<?php

$link = mysqli_connect("127.0.0.1", "root", "passwd", "test");

echo mysqli_real_escape_string($link, "1");

Also, this code produces a segmentation fault:

<?php

$link = mysqli_connect("127.0.0.1", "root", "passwd", "test");

printf("Current character set: %s\n", mysqli_character_set_name($link));

Investigating more deeply, I resolved the problem by removing this from
my.cnf:

character-set-server = utf8
collation-server = utf8_spanish_ci

Using latin1 and latin_swedish_ci, works fine,

This is my ./configure command on Linux:

./configure --enable-cli --with-mysqli=mysqlnd --disable-xmlreader
--disable-xmlwriter --with-apxs2=/usr/bin/apxs2
--with-config-file-path=/etc --enable-mysqlnd

This is the mysqli/mysqlnd part of the phpinfo():

mysqli

MysqlI Support => enabled
Client API library version => mysqlnd 5.0.8-dev - 20102224 - $Id:
65fe78e70ce53d27a6cd578597722950e490b0d0 $
Active Persistent Links => 0
Inactive Persistent Links => 0
Active Links => 0

Directive => Local Value => Master Value
mysqli.allow_local_infile => On => On
mysqli.allow_persistent => On => On
mysqli.default_host => no value => no value
mysqli.default_port => 3306 => 3306
mysqli.default_pw => no value => no value
mysqli.default_socket => no value => no value
mysqli.default_user => no value => no value
mysqli.max_links => Unlimited => Unlimited
mysqli.max_persistent => Unlimited => Unlimited
mysqli.reconnect => Off => Off

mysqlnd

mysqlnd => enabled
Version => mysqlnd 5.0.8-dev - 20102224 - $Id:
65fe78e70ce53d27a6cd578597722950e490b0d0 $
Compression => not supported
SSL => supported
Command buffer size => 4096
Read buffer size => 32768
Read timeout => 31536000
Collecting statistics => Yes
Collecting memory statistics => Yes
Tracing => n/a

$ mysql --version
mysql  Ver 14.14 Distrib 5.1.62, for debian-linux-gnu (i686) using readline
6.2

[#] mysql --version
mysql  Ver 14.14 Distrib 5.1.62, for apple-darwin10.8.0 (i386) using
readline 6.2


Expected result:
----------------
In the first program, 1 as output, in the second program: Current character
set: utf8



Actual result:
--------------
For:

<?php

$link = mysqli_connect("127.0.0.1", "root", "hea101", "demo");

printf("Current character set: %s\n", mysqli_character_set_name($link));

This is the backtrace:

(gdb) run a.php
Starting program: /opt/local/bin/php a.php
Reading symbols for shared libraries .+++++++++ done
Reading symbols for shared libraries . done

...

Program received signal EXC_BAD_ACCESS, Could not access memory.
Reason: KERN_INVALID_ADDRESS at address: 0x0000000000000008
0x000000010016ad0b in php_mysqlnd_conn_charset_name_pub ()
(gdb) bt
#0  0x000000010016ad0b in php_mysqlnd_conn_charset_name_pub ()
#1  0x0000000103193015 in zif_mysqli_character_set_name ()
#2  0x0000000100232d3a in zend_do_fcall_common_helper_SPEC ()
#3  0x0000000100207abb in execute ()
#4  0x00000001001df88b in zend_execute_scripts ()
#5  0x0000000100186c32 in php_execute_script ()
#6  0x0000000100271ed5 in main ()
(gdb)

And for: 

<?php

$link = mysqli_connect("127.0.0.1", "root", "hea101", "demo");

mysqli_real_escape_string($link, "1");

This is the backtrace:

Program received signal EXC_BAD_ACCESS, Could not access memory.
Reason: KERN_INVALID_ADDRESS at address: 0x000000000000001c
0x000000010016fab0 in mysqlnd_cset_escape_slashes ()
(gdb) bt
#0  0x000000010016fab0 in mysqlnd_cset_escape_slashes ()
#1  0x0000000103193aa1 in zif_mysqli_real_escape_string ()
#2  0x0000000100232d3a in zend_do_fcall_common_helper_SPEC ()
#3  0x0000000100207abb in execute ()
#4  0x00000001001df88b in zend_execute_scripts ()
#5  0x0000000100186c32 in php_execute_script ()
#6  0x0000000100271ed5 in main ()
(gdb)



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

Reply via email to