php.net |  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
Votes:1
Avg. Score:5.0 ± 0.0
Reproduced:1 of 1 (100.0%)
Same Version:0 (0.0%)
Same OS:0 (0.0%)
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 you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
From: sergiopaternoster73 at gmail dot com
New email:
PHP Version: OS:

 

 [2015-12-20 09:02 UTC] sergiopaternoster73 at gmail dot com
Description:
------------
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};Server=myserver.domain.com", 'MyUSER', 'MyPWD');

$query = "SELECT [TXTMD] FROM [/BI0/TMATERIAL] WHERE [LANGU] = 'E' AND [MATERIAL] = 'T_PO1234568'";

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

odbc_close($dbConn);

Expected result:
----------------
If I run it with WHERE [LANGU] = '1' I get UTF-8 chars
Array
(
    [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 <http://gnu.org/licenses/gpl.html>
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:
<http://www.gnu.org/software/gdb/bugs/>.
Find the GDB manual and other documentation resources online at:
<http://www.gnu.org/software/gdb/documentation/>.
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/libthread_db.so.1".
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/libstdc++.so.6.0.19-gdb.py", 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

Patches

Pull Requests

History

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

Thanks.
 [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-2024 The PHP Group
All rights reserved.
Last updated: Sat Dec 21 16:01:28 2024 UTC