|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #71171 odbc_fetch_array generates SIGFAULT
Submitted: 2015-12-20 09:02 UTC Modified: 2016-03-06 04:22 UTC
From: sergiopaternoster73 at gmail dot com Assigned: ab (profile)
Status: No Feedback Package: ODBC related
PHP Version: 7.0.1 OS: Linux Ubuntu 14.03
Private report: No CVE-ID: None
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If this is not your bug, you can add a comment by following this link.
If this is your bug, but you forgot your password, you can retrieve your password here.
Bug Type:
From: sergiopaternoster73 at gmail dot com
New email:
PHP Version: OS:


 [2015-12-20 09:02 UTC] sergiopaternoster73 at gmail dot com
When the query returns a non UTF-8 character, odbc_fetch_array generates SIGFAULT
If the record contains normal UTF-8 (for example Chinese characters) it works fine. The SQL Server field containing non UTF-8 chars has been defined as NVARCHAR(40)

Test script:
$dbConn = odbc_connect("Driver={ODBC Driver 11 for SQL Server};", 'MyUSER', 'MyPWD');


$r = odbc_exec($dbConn,$query);
while($record = odbc_fetch_array($r) ) print_r($record);


Expected result:
If I run it with WHERE [LANGU] = '1' I get UTF-8 chars
    [TXTMD] => JLGLQ-0.45-100£¬¹ýÂËÆ÷,ˮϵPES,0.45um,100/°ü

with WHERE [LANGU] = 'E' I get segfault. The actual records contains non UTF-8 chars

Actual result:
edsradmin@SHALSTest:~/apps.cndb/scripts/cndb$ gdb /usr/local/php/7.0.1/bin/php core
GNU gdb (Ubuntu 7.7.1-0ubuntu5~14.04.2) 7.7.1
Copyright (C) 2014 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.  Type "show copying"
and "show warranty" for details.
This GDB was configured as "x86_64-linux-gnu".
Type "show configuration" for configuration details.
For bug reporting instructions, please see:
Find the GDB manual and other documentation resources online at:
For help, type "help".
Type "apropos word" to search for commands related to "word"...
Reading symbols from /usr/local/php/7.0.1/bin/php...done.
[New LWP 16450]
[Thread debugging using libthread_db enabled]
Using host libthread_db library "/lib/x86_64-linux-gnu/".
Core was generated by `php -q ./tmp/odbc_sqlsrv.php'.
Program terminated with signal SIGSEGV, Segmentation fault.
#0  __memcpy_sse2_unaligned () at ../sysdeps/x86_64/multiarch/memcpy-sse2-unaligned.S:116
116     ../sysdeps/x86_64/multiarch/memcpy-sse2-unaligned.S: No such file or directory.
Traceback (most recent call last):
  File "/usr/share/gdb/auto-load/usr/lib/x86_64-linux-gnu/", line 63, in <module>
    from libstdcxx.v6.printers import register_libstdcxx_printers
ImportError: No module named 'libstdcxx'
(gdb) bt
#0  __memcpy_sse2_unaligned () at ../sysdeps/x86_64/multiarch/memcpy-sse2-unaligned.S:116
#1  0x00000000006ecfeb in zend_string_init (str=0x7f6e2ba76080 "", len=18446744073709551612, persistent=0)
    at /home/edsradmin/software/php-7.0.1/Zend/zend_string.h:159
#2  0x00000000006f16ec in php_odbc_fetch_hash (execute_data=0x7f6e2ba14120, return_value=0x7f6e2ba14110, result_type=2)
    at /home/edsradmin/software/php-7.0.1/ext/odbc/php_odbc.c:1812
#3  0x00000000006f18d8 in zif_odbc_fetch_array (execute_data=0x7f6e2ba14120, return_value=0x7f6e2ba14110)
    at /home/edsradmin/software/php-7.0.1/ext/odbc/php_odbc.c:1848
#4  0x0000000000a32ed8 in ZEND_DO_ICALL_SPEC_HANDLER () at /home/edsradmin/software/php-7.0.1/Zend/zend_vm_execute.h:586
#5  0x0000000000a32913 in execute_ex (ex=0x7f6e2ba14030) at /home/edsradmin/software/php-7.0.1/Zend/zend_vm_execute.h:414
#6  0x0000000000a32a25 in zend_execute (op_array=0x7f6e2ba83000, return_value=0x0) at /home/edsradmin/software/php-7.0.1/Zend/zend_vm_execute.h:458
#7  0x00000000009d7c8b in zend_execute_scripts (type=8, retval=0x0, file_count=3) at /home/edsradmin/software/php-7.0.1/Zend/zend.c:1428
#8  0x00000000009451e8 in php_execute_script (primary_file=0x7ffc7fc3fec0) at /home/edsradmin/software/php-7.0.1/main/main.c:2471
#9  0x0000000000a96c73 in do_cli (argc=3, argv=0x2b821c0) at /home/edsradmin/software/php-7.0.1/sapi/cli/php_cli.c:974
#10 0x0000000000a97e37 in main (argc=3, argv=0x2b821c0) at /home/edsradmin/software/php-7.0.1/sapi/cli/php_cli.c:1345


Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2015-12-21 04:20 UTC]
-Assigned To: +Assigned To: ab
 [2015-12-21 04:20 UTC]
@welting could you please have a look into this? I don't have SQL Server :<
 [2016-02-23 13:42 UTC]
-Status: Assigned +Status: Feedback
 [2016-02-23 13:42 UTC]
@sergiopaternoster73 thanks for the report. Currently I cannot reproduce any crash. I've added a test based on your description though;a=commitdiff;h=01e85f3fdc06f99e3c47b2bc2464c5de98347522 . Please provide a complete reproduce snippet that creates a table and populates it with the data.

 [2016-03-06 04:22 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-2020 The PHP Group
All rights reserved.
Last updated: Fri Nov 27 04:01:23 2020 UTC