Bug #71171 [Opn]: odbc_fetch_array generates SIGFAULT

[email protected]
Newsgroups php.bugs
Message-ID <[email protected]>
Edit report at https://bugs.php.net/bug.php?id=71171&edit=1

 ID:                 71171
 Updated by:         [email protected]
 Reported by:        sergiopaternoster73 at gmail dot com
 Summary:            odbc_fetch_array generates SIGFAULT
 Status:             Open
 Type:               Bug
 Package:            ODBC related
 Operating System:   Linux Ubuntu 14.03
 PHP Version:        7.0.1
-Assigned To:        
+Assigned To:        ab
 Block user comment: N
 Private report:     N

 New Comment:

@welting could you please have a look into this? I don't have SQL Server :<


Previous Comments:
------------------------------------------------------------------------
[2015-12-20 09:02:07] 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


------------------------------------------------------------------------



--
Edit this bug report at https://bugs.php.net/bug.php?id=71171&edit=1
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.