Bug #46050 [Opn->Ver]: odbc_next_result corrupts prepared resource
| From: | cmb@php.net | Date: | Mon, 05 Oct 2020 15:35:22 +0000 |
| Subject: | Bug #46050 [Opn->Ver]: odbc_next_result corrupts prepared resource | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-229410@lists.php.net to get a copy of this message | ||
Edit report at https://bugs.php.net/bug.php?id=46050&edit=1
ID: 46050
Updated by: cmb@php.net
Reported by: RQuadling at GMail dot com
Summary: odbc_next_result corrupts prepared resource
-Status: Open
+Status: Verified
Type: Bug
Package: ODBC related
Operating System: Windows XP SP3
PHP Version: 5.3.0alpha2
-Assigned To:
+Assigned To: cmb
Block user comment: N
Private report: N
New Comment:
> [â¦], I doubt this is an issue any more.
Unfortunately, it is. At least there should be no segfault.
Simple reproducer:
<?php
$conn = odbc_connect($dsn, $user, $pass);
$stmt = odbc_prepare($conn, "SELECT 1");
var_dump(odbc_execute($stmt));
var_dump(odbc_fetch_array($stmt));
var_dump(odbc_next_result($stmt));
var_dump(odbc_execute($stmt));
var_dump(odbc_fetch_array($stmt));
?>
Previous Comments:
------------------------------------------------------------------------
[2015-04-13 18:16:12] RQuadling at GMail dot com
WOW. Old bug. Sorry, but I'm not on Windows with MSSQL anymore.
But if I was, I would probably use pdo_sqlsrv, I doubt this is an issue any more.
------------------------------------------------------------------------
[2015-04-11 14:17:56] cmb@php.net
Does this issue still exist with recent PHP versions?
------------------------------------------------------------------------
[2010-04-26 12:23:10] RQuadling at GMail dot com
As requested. Win32 Backtrace.
php__PID__3656__Date__04_26_2010__Time_11_19_52AM__889__Second_Chance_Exception_C0000005.dmp
Type of Analysis Performed Crash Analysis
Machine Name BV-DEV-SVR-4
Operating System Windows Server 2003 Service Pack 2
Number Of Processors 2
Process ID 3656
Process Image C:\php5\php.exe
System Up-Time 9 day(s) 22:59:24
Process Up-Time 00:00:00
Thread 0 - System ID 2296
Entry point php!mainCRTStartup
Create time 26/04/2010 11:19:52
Time spent in user mode 0 Days 0:0:0.93
Time spent in kernel mode 0 Days 0:0:0.15
Function Arg 1 Arg 2 Arg 3 Source
php5!zif_odbc_exec+31c 01b127e8 00000002 10022c5f
php5!zif_odbc_fetch_array+10 00000001 01b127e8 00000000
php5!execute+cdf 01b40080 01b10108 01b40080
php5!execute+4c25 00c0ec28 00c0fed4 00c0fcbc
php5!execute+1f0 01b10108 00c0fed4 00c0fcb8
php5!zend_execute_scripts+be 00000008 00000000 00000003
php5!php_execute_script+1e2 00c0fed4 0040642c 00000001
php!main+a9a 00000004 003c4fc0 003c3730
php!memcpy+160 00000000 00000000 7ffde000
kernel32!BaseProcessStart+23 00402dda 00000000 00000000
PHP5!ZIF_ODBC_EXEC+31CIn
php__PID__3656__Date__04_26_2010__Time_11_19_52AM__889__Second_Chance_Exception_C0000005.dmp the
assembly instruction at
php5!zif_odbc_exec+31c in C:\php5\php5.dll from The PHP Group has caused an access violation
exception (0xC0000005) when trying to read from memory
location 0x00000028 on thread 0
Module Information
Image Name: C:\php5\php5.dll Symbol Type: PDB
Base address: 0x10000000 Time Stamp: Wed Mar 03 20:45:15 2010
Checksum: 0x00569e17 Comments:
COM DLL: False Company Name: The PHP Group
ISAPIExtension: False File Description: PHP Script Interpreter
ISAPIFilter: False File Version: 5.3.2
Managed DLL: False Internal Name: PHP Script Interpreter
VB DLL: False Legal Copyright: Copyright © 1997-2009 The PHP Group
Loaded Image Name: php5.dll Legal Trademarks: PHP
Mapped Image Name: Original filename: php5.dll
Module name: php5 Private Build:
Single Threaded: False Product Name: PHP
Module Size: 5.50 MBytes Product Version: 5.3.2
Symbol File Name: C:\php5\debug\php5.pdb Special Build: &
------------------------------------------------------------------------
[2010-04-23 23:13:04] felipe@php.net
Thank you for this bug report. To properly diagnose the problem, we
need a backtrace to see what is happening behind the scenes. To
find out how to generate a backtrace, please read
http://bugs.php.net/bugs-generating-backtrace.php
for *NIX and
http://bugs.php.net/bugs-generating-backtrace-win32.php
for Win32
Once you have generated a backtrace, please submit it to this bug
report and change the status back to "Open". Thank you for helping
us make PHP better.
------------------------------------------------------------------------
[2010-04-12 17:40:35] RQuadling at GMail dot com
Using PDO-ODBC is fine.
// Connect to the SQL Server using a DNS-less connection.
// $r_Connection = odbc_pconnect("Driver={SQL
Server};Server={$s_Server};Database={$s_Database}", $s_Username, $s_Password);
$r_Connection = new PDO("odbc:Driver={SQL Server Native Client
10.0};Server={$s_Server};Database={$s_Database}", $s_Username, $s_Password);
// Prepare the statement.
// $r_Statement = odbc_prepare($r_Connection, "EXEC
{$s_Database}.dbo.{$s_StoredProc} ?");
$r_Statement = $r_Connection->prepare("EXEC {$s_Database}.dbo.{$s_StoredProc}
?");
// Execute the statement for each parameter.
foreach($a_Params as $s_Param)
{
echo 'About to process : ', $s_Param, PHP_EOL;
// $b_Executed = odbc_execute($r_Statement, array($s_Param));
$b_Executed = $r_Statement->execute(array($s_Param));
do
{
// while(False !== ($a_Row = odbc_fetch_array($r_Statement)))
while(False !== ($a_Row = $r_Statement-
>fetch(PDO::FETCH_ASSOC)))
{
print_r($a_Row);
}
}
// while(True === ($b_MoreResults = odbc_next_result($r_Statement)));
while(True === ($b_MoreResults = $r_Statement->nextRowset()));
$r_Statement->closeCursor();
}
------------------------------------------------------------------------
The remainder of the comments for this report are too long. To view
the rest of the comments, please view the bug report online at
https://bugs.php.net/bug.php?id=46050
--
Edit this bug report at https://bugs.php.net/bug.php?id=46050&edit=1