php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #7582 ODBC or die inside user defined functions
Submitted: 2000-11-01 22:25 UTC Modified: 2001-04-02 00:50 UTC
From: danielc at analysisandsolutions dot com Assigned:
Status: Closed Package: ODBC related
PHP Version: 4.0.3 OS: NT 4.0 SP 6a
Private report: No CVE-ID: None
 [2000-11-01 22:25 UTC] danielc at analysisandsolutions dot com
A crash occurs when ODBC functions are called with an "or die" statement.
BUT this only happens when an error arises
AND the ODBC or die statement is made within a user defined function.

Doing the same thing without a creating a user defined function caused no problem.
Doing the same exact procedures with MySQL functions caused no problem.
This bug didn't exist in PHP 3.0.11.

Samples of each test variation is below, along with a Dr. Watson report.




<?php

# This works fine in PHP 3.0.11
# BUT CRASHES IN 4.0.3

echo "<h3>ODBC field_len or die Called via Function</h3>";
echo "PHP Version: " . phpversion();

function SomeFunction() {
   global $RecordSetFieldCount;
   global $RecordSet;

   for ($Counter = 0; $Counter < $RecordSetFieldCount; $Counter++) {
      echo "<br />Counter: $Counter";

      # Uncommenting one of these causes crash in 4.0.3.
       $Output[] = @odbc_field_len($RecordSet, $Counter+1) or die ("Went beyond field index.");
      # $Output[] = @odbc_field_type($RecordSet, $Counter+1) or die ("Went beyond field index.");
      # $Output[] = @odbc_num_fields() or die ("Went beyond field index.");

      # Uncommenting this works fine in both versions.
      # $Output[] = @odbc_field_len($RecordSet, $Counter+1);
      # $Output[] = @odbc_num_fields();

   }
}

$Connection = @odbc_connect("StatsFInAccess", "", "", SQL_CUR_USE_ODBC);
$QueryString = "select * from States order by SC";
$RecordSet = @odbc_exec($Connection,"$QueryString");
$RecordSetFieldCount = 4;
SomeFunction();

?>





<?php
/*
# This works fine in PHP 3.0.11 and 4.0.3

echo "<h3>ODBC field_len or die Called Directly</h3>";
echo "PHP Version: " . phpversion();

$Connection = @odbc_connect("StatsFInAccess", "", "", SQL_CUR_USE_ODBC);
$QueryString = "select * from States order by SC";
$RecordSet = @odbc_exec($Connection,"$QueryString");
$RecordSetFieldCount = 4;

for ($Counter = 0; $Counter < $RecordSetFieldCount; $Counter++) {
   echo "<br />Counter: $Counter";
   $Output[] = @odbc_field_len($RecordSet, $Counter+1) or die ("Went beyond field index.");
}

*/
?>




<?php
/*
# This works fine in PHP 3.0.11 and 4.0.3

echo "<h3>MySQL field_len or die Called via Function</h3>";
echo "PHP Version: " . phpversion();

function SomeFunction() {
   global $RecordSetFieldCount;
   global $RecordSet;

   for ($Counter = 0; $Counter < $RecordSetFieldCount; $Counter++) {
      echo "<br />Counter: $Counter";
      $Output[] = @mysql_field_len($RecordSet, $Counter) or die ("Went beyond field index.");
   }
}

$Connection = @mysql_connect("localhost", "jdoe", "TheNumberGal");
$Database = @mysql_select_db("StatsF",$Connection);
$QueryString = "select * from States order by SC";
$RecordSet = @mysql_query("$QueryString",$Connection);
$RecordSetFieldCount = 4;
SomeFunction();

*/
?>







<?php
/*
Microsoft (R) Windows NT (TM) Version 4.00 DrWtsn32
Copyright (C) 1985-1996 Microsoft Corp. All rights reserved.



Application exception occurred:
        App:  (pid=242)
        When: 11/1/2000 @ 21:22:4.260
        Exception number: c0000005 (access violation)

*----> System Information <----*
        Computer Name: BASE
        User Name: SYSTEM
        Number of Processors: 1
        Processor Type: x86 Family 6 Model 3 Stepping 4
        Windows Version: 4.0
        Current Build: 1381
        Service Pack: 6
        Current Type: Uniprocessor Free
        Registered Organization: Analysis and Solutions Company
        Registered Owner: Daniel Convissor

*----> Task List <----*
   0 Idle.exe
   2 System.exe
  24 SMSS.exe
  32 CSRSS.exe
  38 WINLOGON.exe
  46 SERVICES.exe
  49 LSASS.exe
  75 SPOOLSS.exe
  91 Apache.exe
  94 Apache.exe
  87 ubsched.exe
  99 mysqld.exe
 153 NPSSVC.exe
 158 RPCSS.exe
 165 TAPISRV.exe
 176 RASMAN.exe
 179 PSTORES.exe
 204 NDDEAGNT.exe
  79 EXPLORER.exe
 201 directcd.exe
  65 hpcron.exe
  50 LOADWC.exe
 231 NTVDM.exe
 171 netscape.exe
 170 NOTEPAD.exe
 242 php.exe
 249 DRWTSN32.exe
   0 _Total.exe

(00400000 - 00400000) 
(77f60000 - 77fbe000) dll\ntdll.dbg
(10000000 - 10000000) 
(77f00000 - 77f5e000) dll\kernel32.dbg
(77e70000 - 77ec5000) dll\user32.dbg
(77ed0000 - 77efc000) dll\gdi32.dbg
(77dc0000 - 77dff000) dll\advapi32.dbg
(77e10000 - 77e67000) dll\rpcrt4.dbg
(776d0000 - 776d8000) dll\wsock32.dbg
(776b0000 - 776c4000) dll\ws2_32.dbg
(78000000 - 7803d000) 
(776a0000 - 776a7000) dll\ws2help.dbg
(77b20000 - 77bd7000) dll\ole32.dbg
(65340000 - 653d2000) oleaut32.dbg
(6a980000 - 6a9b4000) odbc32.dbg
(77aa0000 - 77b15000) COMCTL32.dbg
(77c40000 - 77d7c000) dll\shell32.dbg
(77d80000 - 77db2000) dll\comdlg32.dbg
(77a90000 - 77a9b000) dll\version.dbg
(779c0000 - 779c8000) dll\lz32.dbg
(780a0000 - 780a0000) 
(04a00000 - 04a13000) ..\RES\US\ODBCLAN\\ndebug32\ODBCINT.dll
(04000000 - 04134000) msjet35.DBG
(77bf0000 - 77bf7000) dll\rpcltc1.dbg

State Dump for Thread Id 0xf6

eax=00ce13c4 ebx=00ce16d0 ecx=00000000 edx=00ce1d5c esi=00ce1a40 edi=00000001
eip=04c168d0 esp=0012fddc ebp=0012fdfc iopl=0         nv up ei pl zr na po nc
cs=001b  ss=0023  ds=0023  es=0023  fs=003b  gs=0000             efl=00000246


function: <nosymbols>

*----> Stack Back Trace <----*

FramePtr ReturnAd Param#1  Param#2  Param#3  Param#4  Function Name
0012fdd8 6a996be3 00ee2c04 00000001 00ce0000 007ea710 <nosymbols> 
0012fdfc 6a996a27 00ce1a40 00000001 00000010 007c1698 odbc32!SQLFreeStmt 
0012fe94 10004e6b 007c1a60 007c1500 007c02d0 007c3b10 odbc32!SQLFreeStmt 

*----> Raw Stack Dump <----*
0012fddc  e3 6b 99 6a 04 2c ee 00 - 01 00 00 00 00 00 ce 00  .k.j.,..........
0012fdec  10 a7 7e 00 00 00 00 00 - 00 00 00 00 00 00 00 00  ..~.............
0012fdfc  94 fe 12 00 27 6a 99 6a - 40 1a ce 00 01 00 00 00  ....'j.j@.......
0012fe0c  10 00 00 00 98 16 7c 00 - 10 a7 7e 00 3f 8e 03 10  ......|...~.?...
0012fe1c  40 1a ce 00 01 00 00 00 - 90 ab 7e 00 15 e5 08 10  @.........~.....
0012fe2c  10 a7 7e 00 30 a5 7e 00 - 64 24 08 10 d0 fc 7d 00  ..~.0.~.d$....}.
0012fe3c  4c 15 7c 00 98 16 7c 00 - 94 fe 12 00 00 00 00 00  L.|...|.........
0012fe4c  13 24 08 10 98 16 7c 00 - 30 a5 7e 00 00 15 7c 00  .$....|.0.~...|.
0012fe5c  cf e5 08 10 98 16 7c 00 - b9 ce 08 10 00 15 7c 00  ......|.......|.
0012fe6c  40 01 7c 00 50 cf 08 10 - 80 01 7c 00 50 cf 08 10  @.|.P.....|.P...
0012fe7c  f0 16 7c 00 7c 0e 02 78 - 00 15 7c 00 ac 8d 08 10  ..|.|..x..|.....
0012fe8c  00 15 7c 00 00 15 7c 00 - b8 fe 12 00 6b 4e 00 10  ..|...|.....kN..
0012fe9c  60 1a 7c 00 00 15 7c 00 - d0 02 7c 00 10 3b 7c 00  `.|...|...|..;|.
0012feac  60 1a 7c 00 d0 02 7c 00 - 00 15 7c 00 4c ff 12 00  `.|...|...|.L...
0012febc  e0 1a 40 00 00 00 00 00 - 00 00 00 00 00 00 00 00  ..@.............
0012fecc  00 f0 fd 7f 00 00 00 00 - 00 00 00 00 04 00 00 00  ................
0012fedc  00 00 00 00 00 33 13 00 - 1a 00 00 00 00 f0 fd 7f  .....3..........
0012feec  00 f0 fd 7f 30 00 00 00 - 6c 13 00 78 08 41 03 78  ....0...l..x.A.x
0012fefc  03 ff 12 00 80 66 7e 00 - 00 00 00 00 a0 99 7e 00  .....f~.......~.
0012ff0c  00 00 00 00 18 33 13 00 - 00 00 00 00 00 00 00 00  .....3..........

State Dump for Thread Id 0xc6

eax=00007530 ebx=00000000 ecx=000000f6 edx=00000000 esi=77e726e5 edi=00edff6c
eip=77e72397 esp=00edff24 ebp=00edff48 iopl=0         nv up ei pl zr na po nc
cs=001b  ss=0023  ds=0023  es=0023  fs=0038  gs=0000             efl=00000246


function: InvalidateRect
        77e7237e b89e110000       mov     eax,0x119e
        77e72383 8d542404         lea     edx,[esp+0x4]          ss:01c0e92b=????????
        77e72387 cd2e             int     2e
        77e72389 c20c00           ret     0xc
        77e7238c b885110000       mov     eax,0x1185
        77e72391 8d542404         lea     edx,[esp+0x4]          ss:01c0e92b=????????
        77e72395 cd2e             int     2e
        77e72397 c21400           ret     0x14

*----> Stack Back Trace <----*

FramePtr ReturnAd Param#1  Param#2  Param#3  Param#4  Function Name
00edff48 1008df05 00edff6c 00000000 00000000 00000000 user32!InvalidateRect 

*----> Raw Stack Dump <----*
00edff24  15 27 e7 77 6c ff ed 00 - 00 00 00 00 00 00 00 00  .'.wl...........
00edff34  00 00 00 00 44 ff ed 00 - 66 25 e7 77 e5 26 e7 77  ....D...f%.w.&.w
00edff44  e5 26 e7 77 b8 ff ed 00 - 05 df 08 10 6c ff ed 00  .&.w........l...
00edff54  00 00 00 00 00 00 00 00 - 00 00 00 00 00 00 00 00  ................
00edff64  b0 66 7e 00 b0 66 7e 00 - 00 00 00 00 01 04 00 00  .f~..f~.........
00edff74  f6 00 00 00 1e 00 00 00 - bf da cb 02 9b 00 00 00  ................
00edff84  12 01 00 00 76 36 00 78 - 00 00 00 00 00 00 00 00  ....v6.x........
00edff94  b4 fd 12 0e b0 66 7e 00 - a5 dd 11 80 90 ff ed 00  .....f~.........
00edffa4  8b 74 11 80 dc ff ed 00 - 75 e1 00 78 08 d3 02 78  .t......u..x...x
00edffb4  00 00 00 00 ec ff ed 00 - de 4e f0 77 b0 66 7e 00  .........N.w.f~.
00edffc4  00 00 00 00 b4 fd 12 0e - b0 66 7e 00 b4 fd 12 0e  .........f~.....
00edffd4  c4 ff ed 00 73 3b f0 77 - ff ff ff ff 44 b9 f3 77  ....s;.w....D..w
00edffe4  38 d2 f3 77 00 00 00 00 - 00 00 00 00 00 00 00 00  8..w............
00edfff4  1b 36 00 78 b0 66 7e 00 - 00 00 00 00 07 00 00 00  .6.x.f~.........
00ee0004  01 01 00 00 ee ff ee ff - 00 00 00 00 00 00 7b 00  ..............{.
00ee0014  00 80 0f 00 00 00 ee 00 - 00 01 00 00 38 00 ee 00  ............8...
00ee0024  00 00 fe 00 f8 00 00 00 - 01 00 00 00 c8 04 7b 00  ..............{.
00ee0034  00 00 00 00 01 02 07 00 - 01 01 08 00 58 2d 50 6f  ............X-Po
00ee0044  77 65 72 65 64 2d 42 79 - 3a 20 50 48 50 2f 34 2e  wered-By: PHP/4.
00ee0054  30 2e 33 0d 0a 43 6f 6e - 74 65 6e 74 2d 74 79 70  0.3..Content-typ

*/
?>

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2000-11-03 19:31 UTC] waldschrott@php.net
had no crash (w2k,4.0.4dev), try 4.0.4 as far as it is out
and if it still crashes I?ll try sth. different
 [2000-11-09 21:04 UTC] danielc at analysisandsolutions dot com
Please advise where I can obtain a compiled binary of 4.0.4dev for Win32.  I'll be glad to test it.  Looks like CVS and snaps.php.net send source code.  Don't know where else to turn.
 [2000-12-07 12:01 UTC] sniper@php.net
Get the latest build from http://www.php4win.de/
and reopen if problem still exists with it.

--Jani
 [2000-12-19 00:10 UTC] danielc at analysisandsolutions dot com
The problem still exists in php4_0_4-dev-win32-20001123.
 [2001-02-26 15:11 UTC] danielc at analysisandsolutions dot com
Problem still exists in php4_0_5-dev-win32-20010220
 [2001-04-01 20:19 UTC] kalowsky@php.net
after trying numerous methods to reproduce this, I cannot.  
The only thing I can phathom is that your 
$RecordSetFieldCount is set inaccurately, but again I 
couldn't reproduce the described behavior when over running 
it.

Mind you, I am using PHP in a CGI format, and on Win98SE.  
PHP version is PHP4.0.5RC4.
 [2001-04-02 00:50 UTC] danielc at analysisandsolutions dot com
Hi kalowsky:

Please give me a URL where I can downlad PHP4.0.5RC4 and I'll be glad to test it out again ASAP.

--Dan
 [2017-03-10 15:34 UTC] keemstar at gmail dot com
i learn to cheat and do lsd daily XDDDD
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Sat Apr 20 03:01:28 2024 UTC