php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #59158 Decoding BLOB/CLOB Resources
Submitted: 2010-04-13 12:05 UTC Modified: 2021-10-17 04:22 UTC
Votes:4
Avg. Score:4.8 ± 0.4
Reproduced:4 of 4 (100.0%)
Same Version:0 (0.0%)
Same OS:1 (25.0%)
From: will at flourishlib dot com Assigned: cmb (profile)
Status: No Feedback Package: PDO_IBM (PECL)
PHP Version: 5.2.12 OS: Windows
Private report: No CVE-ID: None
Have you experienced this issue?
Rate the importance of this bug to you:

 [2010-04-13 12:05 UTC] will at flourishlib dot com
Description:
------------
When retrieving BLOB data from a DB2 LUW 9.7.1 database using this extension, I receive a resource back. When I try to use such a resource with stream_get_contents(), PHP segfaults. This happens with PHP 5.2.12 in Windows XP, PHP 5.1.6 on CentOS 5 and PHP 5.3.1 on Fedora 12.

When retrieve CLOB data from the SYSCAT.CHECKS catalog view, and trying to use stream_get_contents(), on CentOS 5 with 5.1.6, I get a blank string. With 5.2.12 on Windows and 5.3.1 on Fedora, PHP segfaults.

The columns can be retrieved using the ibm_db2 extension without issues on all platforms, and the pdo_odbc extension in Windows.

Expected result:
----------------
I should be able to retrieve a string of character or binary data from the resource.

Actual result:
--------------
Either a segmentation fault or a blank string.

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2010-04-17 12:43 UTC] kontakt at beberlei dot de
I experience the same issue, here is the GDB backtrace for this:

Program received signal SIGSEGV, Segmentation fault.
lob_stream_read (stream=0x8a8bab4, buf=0x8c0c6c8 "\300\306\300\b\300\306\300\b\034Ċ\b", count=8192)
    at /home/benny/downloads/ibmdb2/PDO_IBM-1.3.2/ibm_statement.c:141
141		switch (col_res->data_type) {
(gdb) bt
#0  lob_stream_read (stream=0x8a8bab4, buf=0x8c0c6c8 "\300\306\300\b\300\306\300\b\034Ċ\b", count=8192)
    at /home/benny/downloads/ibmdb2/PDO_IBM-1.3.2/ibm_statement.c:141
#1  0x0837e47b in php_stream_fill_read_buffer (stream=0x8a8bab4, size=<value optimized out>) at /home/benny/downloads/php-5.3.2/main/streams/streams.c:562
#2  0x0837e761 in _php_stream_read (stream=0x8a8bab4, buf=0x8c0a6c0 "\270\246\300\b\270\246\300\b\034&#266;\b", size=8192)
    at /home/benny/downloads/php-5.3.2/main/streams/streams.c:605
#3  0x0837f47f in _php_stream_copy_to_mem (src=0x8a8bab4, buf=0xbfffcbac, maxlen=4294967295, persistent=0)
    at /home/benny/downloads/php-5.3.2/main/streams/streams.c:1280
#4  0x0833ab29 in zif_stream_get_contents (ht=1, return_value=0x8bfcc74, return_value_ptr=0x0, this_ptr=0x0, return_value_used=1)
    at /home/benny/downloads/php-5.3.2/ext/standard/streamsfuncs.c:425
#5  0x083d906e in execute_internal (execute_data_ptr=0x8abbf90, return_value_used=1) at /home/benny/downloads/php-5.3.2/Zend/zend_execute.c:1260
#6  0x012eaafe in xdebug_execute_internal (current_execute_data=0x8abbf90, return_value_used=1) at /usr/local/zend/temp/xdebug/xdebug.c:1631
#7  0x083e0dbb in zend_do_fcall_common_helper_SPEC (execute_data=0x8abbf90) at /home/benny/downloads/php-5.3.2/Zend/zend_vm_execute.h:315
#8  0x083db53e in execute (op_array=0x8a8b3e8) at /home/benny/downloads/php-5.3.2/Zend/zend_vm_execute.h:104
#9  0x012ea7b7 in xdebug_execute (op_array=0x8a8b3e8) at /usr/local/zend/temp/xdebug/xdebug.c:1562
#10 0x083b80c6 in zend_execute_scripts (type=8, retval=0x0, file_count=3) at /home/benny/downloads/php-5.3.2/Zend/zend.c:1194
#11 0x08366e28 in php_execute_script (primary_file=0xbffff190) at /home/benny/downloads/php-5.3.2/main/main.c:2260
#12 0x0843886d in main (argc=2, argv=0xbffff304) at /home/benny/downloads/php-5.3.2/sapi/cli/php_cli.c:1192

PHP code is:

stream_get_contents($row['CONTENT']);

using a PDO::fetchAll retrieving the data.

Ironically using PDO::fetch, no segfaulting behaviour is occuring.
 [2010-04-19 03:11 UTC] abhargav at in dot ibm dot com
Hi,

I will analyze the issue and will update you.

Regards,
Ambrish Bhargava
 [2010-07-30 16:51 UTC] will at flourishlib dot com
I've found that even using fetch() causes the issue, if I try 
to get the stream content after I've fetched all of the rows. 
I don't know if fetching just one more row causes it, or if it 
is because I am exhausting the cursor.

I worked around this by preemptively decoding all resources as 
I am looping over the returned rows.
 [2014-04-30 14:38 UTC] tomaz at inetis dot com
Any progress on this? I have the same problem on php 5.5.11 and pdo ibm 1.3.3

Program received signal SIGSEGV, Segmentation fault.
lob_stream_read (stream=0x7ffc804e2998, buf=0x7ffc80542290 "\200\"T\200\374\177", count=8192) at /home/tomazd/projekti/nlb/izracuni-php/src/PDO_IBM-1.3.3/ibm_statement.c:141
 [2021-10-06 10:55 UTC] cmb@php.net
-Status: Open +Status: Feedback -Assigned To: +Assigned To: cmb
 [2021-10-06 10:55 UTC] cmb@php.net
Is this still an issue with any of the actively supported PHP
versions[1], or do you get an empty string now, like reported in
bug #81495?

[1] <https://www.php.net/supported-versions.php>
 [2021-10-17 04:22 UTC] pecl-dev 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: Tue Mar 19 07:01:29 2024 UTC