ID:               13136
 Updated by:       [EMAIL PROTECTED]
 Reported By:      [EMAIL PROTECTED]
-Status:           Open
+Status:           Feedback
 Bug Type:         Reproducible crash
 Operating System: Win2000 SP2
 PHP Version:      4.0.6
 New Comment:

Could you update PHP version that you've tested most recently?


Previous Comments:
------------------------------------------------------------------------

[2001-09-04 12:52:49] [EMAIL PROTECTED]

First, I forgot to mention that the crash happens in release as well as
in debug version.
Second, I discovered bug No. 12620 and tried to compile with
ZEND_DISABLE_MEMORY_CACHE set to 1. Result: still crashes in debug
version.


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

[2001-09-04 12:50:50] [EMAIL PROTECTED]

First, I forgot to mention that the crash happens in release as well as
in debug version.
Second, I discovered bug No. 12620 and tried to compile with
ZEND_DISABLE_MEMORY_CACHE set to 1. Result: still crashes in debug
version.


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

[2001-09-04 12:36:20] [EMAIL PROTECTED]

I'm working with an Access 2000 database (MDAC 2.6) via ODBC on W2K
SP2. The following code 

will cause PHP 4.0.6 to crash with an access violation. The same
bahaviour was experienced with version 4.0.2.

Save the two files and open test.php in browser to reproduce. (Sorry,
must post long script as I haven't any other place to put it. And I got
no gdb.)

-------------------------------------- crash code: test.php
<html>
<body>
<?php

include('test2.php');

 causeAccessViolation();

?>
</body>
</html>
-------------------------------------- crash code: test.php END

-------------------------------------- crash code: test2.php

<?php


function connect()
{

// Put some db here; my DNS was 'eqms'
    $db = odbc_connect('eqms', '', '')
        or die(__FILE__.": Unable to connect to database!");

    return $db;
}

function disconnect($db)
{
    if(isset($db) && $db != 0)
        odbc_close($db);
}

function denyAccess()
{
    echo 'NO ACCESS';
    exit();
}

function causeAccessViolation()
{

$db = connect();
if(!$db)
    die($db_err);


// Put some query here
$query = "SELECT MitarbeiterID, ProjektID
             FROM
             ProjektMitarbeiter
             WHERE
             MitarbeiterID = 45 AND
         ProjektID = 45";

             $query_result = odbc_exec($db, $query);
             if(!$query_result)
                    die($db_err);

             $row = odbc_fetch_row($query_result);

/* 1     odbc_free_result($query_result);
         disconnect($db);

*/

         denyAccess();

/*  2 COMMENT OUT THE NEXT TWO LINES AND COMMENT IN THE LINES AT 1
    AND PHP WON'T CRASH ANYMORE

*/
                odbc_free_result($query_result);
                disconnect($db);

}


 ?>

-------------------------------------- crash code: test2.php END


I debugged PHP and the results showed that PHP crashed during shutdown
somewhere below 

list_entry_destructor() in zend_list.c:

----------------- snippet zend_list.c

void list_entry_destructor(void *ptr)
{
        zend_rsrc_list_entry *le = (zend_rsrc_list_entry *) ptr;
        zend_rsrc_list_dtors_entry *ld;
        
        if (zend_hash_index_find(&list_destructors, le->type,(void **)
&ld)==SUCCESS) {
                switch (ld->type) {
                        case ZEND_RESOURCE_LIST_TYPE_STD:
                                if (ld->list_dtor) {
                                        (ld->list_dtor)(le->ptr);
                                }
                                break;
                        case ZEND_RESOURCE_LIST_TYPE_EX:
                                if (ld->list_dtor_ex) {
                                        ld->list_dtor_ex(le); /******** CRASH HERE 
********/
                                }
                                break;
                        EMPTY_SWITCH_DEFAULT_CASE()
                }
        } else {
                zend_error(E_WARNING,"Unknown list entry type in request shutdown 

(%d)",le->type);
        }
}

----------------- snippet zend_list.c END

When I dug a bit deeper I saw the following happening:
ld->list_dtor_ex had the follwing values on two consecutive calls:
First: _close_odbc_conn(_zend_rsrc_list_entry *)
Second: _free_odbc_result(_zend_rsrc_list_entry *) 
----> after that some ODBC32 functions are called then CRASH

BUT on another page that didn't cause PHP to crash and utilized odbc,
it had the following values on three consecutive calls:
First: _free_odbc_result(_zend_rsrc_list_entry *)
Second: _file_fopen_dtor(_zend_rsrc_list_entry *)
Third: _close_odbc_conn(_zend_rsrc_list_entry *)



I'm no expert for the PHP source (was the first time I saw it,
actually) but I imagine the crash has something to do with the wrong
order of the calls, if it's not something with the odbc drivers
(Jet...). Especially, notice that, when you change the position of the
two lines that free the odbc result and close the connection, PHP
behaves normally (see test2.php).

hope that helps,

kai


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


-- 
Edit this bug report at http://bugs.php.net/?id=13136&edit=1


-- 
PHP Development Mailing List <http://www.php.net/>
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to