#22709 [Fbk->Opn]: Sometime crash when database unavailable

From: Date: Sat, 15 Mar 2003 20:22:06 +0000
Subject: #22709 [Fbk->Opn]: Sometime crash when database unavailable
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-35679@lists.php.net to get a copy of this message
ID: 22709 User updated by: Vladimir dot Michl at seznam dot cz Reported By: Vladimir dot Michl at seznam dot cz -Status: Feedback +Status: Open Bug Type: InterBase related Operating System: Any -PHP Version: 4.3.2RC1 +PHP Version: 4.2.3 New Comment: Really, I test it on 4.2.3 but if I see to CVS, to interbase.c, this bug is not fixed. I discover this bug in php 4.1.1, but now I have time to locate problem. I have experience, that PHP team if see too old version of PHP that reject patch. Patch may fix some problem, not fixed in actual version, but too old version of PHP -> reject patch. See to source: get_link_trans may return NULL in ib_link, but code after call get_link_trans not handle this situation. Here is path in unified diff: --- interbase.c.orig Fri Mar 14 14:11:51 2003 +++ interbase.c Fri Mar 14 14:21:47 2003 @@ -1572,7 +1572,11 @@ { TSRMLS_FETCH(); - if (trans_n == 0 && ib_link->trans[0] == NULL) { + if (ib_link == NULL){ + php_error(E_WARNING, "Database link is not valid"); + return FAILURE; + }; + if (trans_n == 0 && ib_link->trans[0] == NULL) { if (isc_start_transaction(IB_STATUS, &ib_link->trans[0], 1, &ib_link->link, 0, NULL)) { _php_ibase_error(); return FAILURE; @@ -1609,6 +1613,10 @@ break; } + if (ib_link == NULL) { + php_error(E_WARNING, "Database link is not valid"); + RETURN_FALSE; + } if (ib_link->trans[trans_n] == NULL) { php_error(E_WARNING, "Trying to commit or rollback an already handled transaction"); RETURN_FALSE; Previous Comments: ------------------------------------------------------------------------ [2003-03-14 19:27:11] sniper@php.net Are you really using 4.3.2RC1? Where did you get it? :) In any case, please provide any patches in the unified diff format. ( diff -u ) ------------------------------------------------------------------------ [2003-03-14 13:40:53] Vladimir dot Michl at seznam dot cz PHP sometime crash, when interbase database go to unavailable during script execution. Problem is, when get_link_trans return NULL in ib_link. I localise problem and here is fix (fixed in _php_ibase_def_trans and _php_ibase_trans_end): *** interbase.c.orig Fri Mar 14 14:11:51 2003 --- interbase.c Fri Mar 14 14:21:47 2003 *************** *** 1572,1578 **** { TSRMLS_FETCH(); ! if (trans_n == 0 && ib_link->trans[0] == NULL) { if (isc_start_transaction(IB_STATUS, &ib_link->trans[0], 1, &ib_link->link, 0, NULL)) { _php_ibase_error(); return FAILURE; --- 1572,1582 ---- { TSRMLS_FETCH(); ! if (ib_link == NULL){ ! php_error(E_WARNING, "Database link is not valid"); ! return FAILURE; ! }; ! if (trans_n == 0 && ib_link->trans[0] == NULL) { if (isc_start_transaction(IB_STATUS, &ib_link->trans[0], 1, &ib_link->link, 0, NULL)) { _php_ibase_error(); return FAILURE; *************** *** 1609,1614 **** --- 1613,1622 ---- break; } + if (ib_link == NULL) { + php_error(E_WARNING, "Database link is not valid"); + RETURN_FALSE; + } if (ib_link->trans[trans_n] == NULL) { php_error(E_WARNING, "Trying to commit or rollback an already handled transaction"); RETURN_FALSE; ------------------------------------------------------------------------ -- Edit this bug report at http://bugs.php.net/?id=22709&edit=1

« previous php.bugs (#35679) next »