Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:18718 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 43184 invoked by uid 1010); 8 Sep 2005 12:18:23 -0000 Delivered-To: ezmlm-scan-internals@lists.php.net Delivered-To: ezmlm-internals@lists.php.net Received: (qmail 43169 invoked from network); 8 Sep 2005 12:18:23 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 8 Sep 2005 12:18:23 -0000 X-Host-Fingerprint: 64.233.184.194 wproxy.gmail.com Linux 2.4/2.6 Received: from ([64.233.184.194:39195] helo=wproxy.gmail.com) by pb1.pair.com (ecelerity 2.0 beta r(6323M)) with SMTP id 7E/13-23233-E0C20234 for ; Thu, 08 Sep 2005 08:18:23 -0400 Received: by wproxy.gmail.com with SMTP id 70so1225686wra for ; Thu, 08 Sep 2005 05:18:19 -0700 (PDT) DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=beta; d=gmail.com; h=received:message-id:date:from:reply-to:to:subject:cc:in-reply-to:mime-version:content-type:content-transfer-encoding:content-disposition:references; b=YXAuMrSAhQUDMrch9CHfTJU21PkrbZ1qlBSSq9xQcWH5f2yjALCBGKWoqUOJcXcsqbFg/g2eK50hsT33+43NbkrITJfLLxM4UFIC+AfGXwfptZlyBzDKBJlDKjQ4uJUID9c9HsPpDGEgG+IV1/oViAD9zguDCxli0f+XzXyxvNM= Received: by 10.54.121.12 with SMTP id t12mr5996477wrc; Thu, 08 Sep 2005 05:18:19 -0700 (PDT) Received: by 10.54.153.20 with HTTP; Thu, 8 Sep 2005 05:18:19 -0700 (PDT) Message-ID: <4e89b42605090805185f916d96@mail.gmail.com> Date: Thu, 8 Sep 2005 08:18:19 -0400 Reply-To: kingwez@gmail.com To: Stanislav Malyshev Cc: Sara Golemon , internals@lists.php.net In-Reply-To: Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable Content-Disposition: inline References: <002301c5b40d$0f75a570$85901a44@lighthammer> Subject: Re: [PHP-DEV] zend_list_delete() doesn't. From: kingwez@gmail.com (Wez Furlong) On 9/8/05, Stanislav Malyshev wrote: > SG>> SG>> $fp1 =3D fopen('test', 'w'); > SG>> $fp2 =3D $fp1; /* Still a single zval* and le->refcount =3D=3D 1 */ > SG>> $fp3 =3D &$fp1; /* Two zval*s now and le->refcount =3D=3D 2 */ > SG>> > SG>> fclose($fp1); >=20 > I think this was discussed before, though I may be mistaken. We talked about this for the revised oci8 code; we adopted the practice of ZVAL_NULL()ing the zval just after we zend_list_delete() it, because the updated oci8 codebase can return zvals that reference the same underlying list resource. You could arrive at a similar kind of problem that Sara pointed out by doing this: $a =3D oci_connect(...); $b =3D oci_connect(...); // $b is a different zval from $a, but refs the same resource oci_close($a); // kills $a, but $b still owns a ref oci_close($a); // since $a still contains the resource id, this now kills the resource, // breaking $b We made oci_close() set $a to NULL before returning, to avoid this refcount skewing. > The problem > here is that you expect fclose to kill the resource, however $fp2 still > refers it. Looks like there should be two operations for resource - one i= s > usual delref called when variable is destroyed and second is "hard kill" > called when something like fclose is used and invalidating all referring > variables. I remember there were some issues with that, but I can't > rememebr what they were... IMO, "hard kill" doesn't really fit in a system that uses reference counts; you either use reference counts, or don't. There are cases (particularly in streams) where we hold the resource ID to guarantee that a pointer remains valid. Hard kill would break the reference counting contract and lead to a segv. --Wez.