From:             c_rl_h at hotmail dot com
Operating system: Linux AMD 64
PHP version:      4.3.7
PHP Bug Type:     ODBC related
Bug description:  Segmentation fault when returning more than 3 results via odbc_result

Description:
------------
[EMAIL PROTECTED]:/home/web> uname -a
Linux dogregr 2.4.21-143-smp #1 SMP Thu Oct 30 23:48:07 UTC 2003 x86_64
unknown

[EMAIL PROTECTED]:/home/web> cat /proc/meminfo
        total:    used:    free:  shared: buffers:  cached:
Mem:  7659995136 7491145728 168849408        0 327503872 6304870400
Swap: 2147467264 12349440 2135117824

[EMAIL PROTECTED]:/home/web> cat /proc/cpuinfo
processor       : 0
vendor_id       : AuthenticAMD
cpu family      : 15
model           : 5
model name      : AMD Opteron(tm) Processor 848
stepping        : 8
cpu MHz         : 2190.156
cache size      : 1024 KB
fpu             : yes
fpu_exception   : yes
cpuid level     : 1
wp              : yes
flags           : fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca
cmov
bogomips        : 4364.69
TLB size        : 1088 4K pages
clflush size    : 64
address sizes   : 40 bits physical, 48 bits virtual
power management: ts ttp

processor       : 1
vendor_id       : AuthenticAMD
cpu family      : 15
model           : 5
model name      : AMD Opteron(tm) Processor 848
stepping        : 8
cpu MHz         : 2190.156
cache size      : 1024 KB
fpu             : yes
fpu_exception   : yes
cpuid level     : 1
wp              : yes
flags           : fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca
cmov
bogomips        : 4377.80
TLB size        : 1088 4K pages
clflush size    : 64
address sizes   : 40 bits physical, 48 bits virtual
power management: ts ttp

processor       : 2
vendor_id       : AuthenticAMD
cpu family      : 15
model           : 5
model name      : AMD Opteron(tm) Processor 848
stepping        : 8
cpu MHz         : 2190.156
cache size      : 1024 KB
fpu             : yes
fpu_exception   : yes
cpuid level     : 1
wp              : yes
flags           : fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca
cmov
bogomips        : 4377.80
TLB size        : 1088 4K pages
clflush size    : 64
address sizes   : 40 bits physical, 48 bits virtual
power management: ts ttp

processor       : 3
vendor_id       : AuthenticAMD
cpu family      : 15
model           : 5
model name      : AMD Opteron(tm) Processor 848
stepping        : 8
cpu MHz         : 2190.156
cache size      : 1024 KB
fpu             : yes
fpu_exception   : yes
cpuid level     : 1
wp              : yes
flags           : fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca
cmov
bogomips        : 4377.80
TLB size        : 1088 4K pages
clflush size    : 64
address sizes   : 40 bits physical, 48 bits virtual
power management: ts ttp

configure line:
./configure --with-ibm-db2=/home/web/sqllib --enable-debug
--with-apxs=/usr/local/apache/bin/apxs

Apache version:
Apache 1.3.31

To test this, I simplified the page down to the reproduce code posted
below.  The error seems to occur when getting the results via odbc_result.
 

If I try to get more than three results of a result set, PHP seems to
crash.  If I comment out the fourth result (eg. $last_communication =
odbc_result($result, 4);) the page will return the results for the first
three successfully.  Any amount of results over three will cause the
failure.  Another thing I tried was switching the integer field to the
actual name of the field with the same result.

I tried to re-work the code to use odbc_fetch_array and odbc_fetch_into,
but those failed as well.  The odbc_result_all function did return all of
the proper results successfully.

Reproduce code:
---------------
<HTML><HEAD><TITLE>test</TITLE></HEAD><BODY>
<?PHP
$dbconn = odbc_pconnect($opsdb, $opsdbuser, $opsdbpass);
$query = "select hostname, bit, status, last_communication from slaves for
read only";
$result = odbc_exec($dbconn, $query);
while ( odbc_fetch_row($result))
{
        
    $hostname = odbc_result($result,1);
    $bit = odbc_result($result, 2);
    $status = odbc_result($result, 3);
    $last_communication = odbc_result($result, 4);
    echo "$hostname, $bit, $status,    
          $last_communication<BR>\n";
}
?>
</BODY></HTML>

Expected result:
----------------
I expected 1029 rows to be returned.

Actual result:
--------------
dogregr:/usr/local/apache/bin # gdb /usr/local/apache/bin/httpd
GNU gdb 5.3
Copyright 2002 Free Software Foundation, Inc.
GDB is free software, covered by the GNU General Public License, and you
are
welcome to change it and/or distribute copies of it under certain
conditions.
Type "show copying" to see the conditions.
There is absolutely no warranty for GDB.  Type "show warranty" for
details.
This GDB was configured as "x86_64-suse-linux"...
(gdb) run -X
        Keeping /usr/local/apache/bin/httpd...
Starting program: /usr/local/apache/bin/httpd -X
[New Thread 1024 (LWP 19645)]
[Mon Jun 14 11:43:13 2004] [warn] module mod_php4.c is already added,
skipping

Program received signal SIGSEGV, Segmentation fault.
[Switching to Thread 1024 (LWP 19645)]
0x0000002a95b9e389 in .memcpypreloop () from /lib64/libc.so.6
(gdb)

-- 
Edit bug report at http://bugs.php.net/?id=28777&edit=1
-- 
Try a CVS snapshot (php4):  http://bugs.php.net/fix.php?id=28777&r=trysnapshot4
Try a CVS snapshot (php5):  http://bugs.php.net/fix.php?id=28777&r=trysnapshot5
Fixed in CVS:               http://bugs.php.net/fix.php?id=28777&r=fixedcvs
Fixed in release:           http://bugs.php.net/fix.php?id=28777&r=alreadyfixed
Need backtrace:             http://bugs.php.net/fix.php?id=28777&r=needtrace
Need Reproduce Script:      http://bugs.php.net/fix.php?id=28777&r=needscript
Try newer version:          http://bugs.php.net/fix.php?id=28777&r=oldversion
Not developer issue:        http://bugs.php.net/fix.php?id=28777&r=support
Expected behavior:          http://bugs.php.net/fix.php?id=28777&r=notwrong
Not enough info:            http://bugs.php.net/fix.php?id=28777&r=notenoughinfo
Submitted twice:            http://bugs.php.net/fix.php?id=28777&r=submittedtwice
register_globals:           http://bugs.php.net/fix.php?id=28777&r=globals
PHP 3 support discontinued: http://bugs.php.net/fix.php?id=28777&r=php3
Daylight Savings:           http://bugs.php.net/fix.php?id=28777&r=dst
IIS Stability:              http://bugs.php.net/fix.php?id=28777&r=isapi
Install GNU Sed:            http://bugs.php.net/fix.php?id=28777&r=gnused
Floating point limitations: http://bugs.php.net/fix.php?id=28777&r=float

Reply via email to