Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:90935 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 11446 invoked from network); 26 Jan 2016 10:50:46 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 26 Jan 2016 10:50:46 -0000 Authentication-Results: pb1.pair.com smtp.mail=julienpauli@gmail.com; spf=pass; sender-id=pass Authentication-Results: pb1.pair.com header.from=julienpauli@gmail.com; sender-id=pass Received-SPF: pass (pb1.pair.com: domain gmail.com designates 74.125.82.42 as permitted sender) X-PHP-List-Original-Sender: julienpauli@gmail.com X-Host-Fingerprint: 74.125.82.42 mail-wm0-f42.google.com Received: from [74.125.82.42] ([74.125.82.42:37572] helo=mail-wm0-f42.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id D5/44-10534-48F47A65 for ; Tue, 26 Jan 2016 05:50:44 -0500 Received: by mail-wm0-f42.google.com with SMTP id n5so123360832wmn.0 for ; Tue, 26 Jan 2016 02:50:44 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:sender:in-reply-to:references:from:date:message-id :subject:to:cc:content-type; bh=FMeotT63IjyB0gPMARbNOX13W6VbeRRNw9Vh4An0Z9Y=; b=w+qpt+TW2DCeBbGmSODvu1gp5NA29axd/slZtutE1H+H+M4RMrsEj00o52kBFpc4CN H5UqAbGNzP3qzAbD4pVd8ly8OsR+EJ2dEojzohPvv0xovcZwC6yaTFU6WN7a2u6KGh7l IdWAks+ooKQAZK5xMsoTI5ziiFpbKjEYiIo68l0uWRyrTn7DSgzemibFTvVhDCC0V/wx T8UQOjGRvVy9l/q7R0Q5y55EV1r43h2AsZC70o9P2Upw4OwAMB8/ozPCZGRv+qSaYt6n /Pht3FK04GQfBvvvpIYuMO83W9TdMhAfcK1FTPsq78u6URNs7EKWXMT/8X6vR1qVZCBQ 5M7w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:sender:in-reply-to:references:from :date:message-id:subject:to:cc:content-type; bh=FMeotT63IjyB0gPMARbNOX13W6VbeRRNw9Vh4An0Z9Y=; b=WJ6H8lU6Zn/gEBlenzlFk1RuBzPML3jIDMPoO9Z2ckjcYi6bNS+fFPsWVZ7MWPdltH QbnFeVYnlHL+VS45HRLZ3D738Hl4b0cm8jP9S0LCZIZNLBqoc5kbtLI+xSaWO7qhkBgT uS1w6BXqgC4Iq9ku34AH9sR5Ptwdgx2n8fRNo4dXQurcz/SL/1SZF7D8LAS6zZvhBDnB J+i0FIP4t1yihu8pgQUeO6FHtmPdgz2mOSBRVQgMogKItti3fUq/86SPw+lychP99ZHB ccIsmwkDxXygVSAW9MoODzEiceyGUqnFe3KVOARn128VMu7iU0y+8VFtLxivD0/8vWGV zKdQ== X-Gm-Message-State: AG10YOR88pFYSA9cLiAB4kiviutQZQHtEyIqgWqxxVX4KA/VXpxeqcUb9ep4faUlxpX6UU4mFSPy7//xb2+NGg== X-Received: by 10.194.91.180 with SMTP id cf20mr22627643wjb.121.1453805441358; Tue, 26 Jan 2016 02:50:41 -0800 (PST) MIME-Version: 1.0 Sender: julienpauli@gmail.com Received: by 10.194.80.42 with HTTP; Tue, 26 Jan 2016 02:50:01 -0800 (PST) In-Reply-To: References: <9D.00.64206.7C430A65@pb1.pair.com> <0D.E3.12955.15522A65@pb1.pair.com> Date: Tue, 26 Jan 2016 11:50:01 +0100 X-Google-Sender-Auth: eWXP195E9Z-7JiV5Y6BHlqbKauQ Message-ID: To: Yasuo Ohgaki , Daniel Lowrey Cc: Umberto Salsi , "internals@lists.php.net" Content-Type: text/plain; charset=UTF-8 Subject: Re: [PHP-DEV] Severe safety fail in file access and stream filters From: jpauli@php.net (Julien Pauli) On Tue, Jan 26, 2016 at 5:15 AM, Yasuo Ohgaki wrote: > Hi Umberto, > > On Fri, Jan 22, 2016 at 9:49 PM, Umberto Salsi wrote: >> thank you very much for the reply, I now start understanding better what >> happen and why currently i/o cannot be handled in user's space. > > You're welcome. > I think you have pointed out important missing parts in PHP. > >> Rather than an array of error, which might be quite expensive to handle, >> why not a simple "char * lasterror" field added to the stream struct, >> normally set to NULL, where a description of the last error occurred may >> be stored? The high-level functions, that is PHP fopen, fread, fwrite, >> fflush, fseek, fclose, may then check that string and, if set, trigger >> E_WARNING with a meaningful message after having reset that string back >> to NULL again. Many C libraries already provide such error strings, >> starting from the same C strerror(). > > Pgsql's "notice" logging is implemented this way at first. Then I changed > it to array of notices recently. (Notice is raised during > transaction, for example) > > It's very difficult or impossible to detect where something wrong happened > if there is only the last error. That's the reason why pgsql module is changed > to have array of notices. > > The same would happen in streams, so it's better to store all errors during > operation. Zend hash is extremely fast and good enough for logging errors, > so we don't have to worry overheads. > >> >> The same should then be done with the filters, which currently only may >> return PSFS_ERR_FATAL, but might have their "char * lasterror" string >> too with the same purpose. Knowing the exact reason of the failure is >> essential to distinguish, for example, a dead disk drive or corrupted file >> system, from a bare file mistakenly opened with the wrong decompressor >> or a file which was badly encoded. > > I agree. > >> >> Then all the specific stream and filter implementations can be adjusted >> to set that error string; for those still not fixed that string remains >> NULL and fopen, ferror, etc. will not report the error just as they do >> today, and will be fixed later step by step. > > Agree here, too. > Someone have to volunteer for this. It's not difficult for people on this list. > I have too many backlogs for PHP project, so I hope someone volunteers > for this. > > Regards, > > -- > Yasuo Ohgaki > yohgaki@ohgaki.net > > -- > PHP Internals - PHP Runtime Development Mailing List > To unsubscribe, visit: http://www.php.net/unsub.php > I think what we should do is sit around the table with people interested (Daniel Lowrey may be one of them), and plan a full rewrite of streams for PHP next major (PHP 8). I don't think addind stuff to next minors is a good idea, knowing we must prevent BC breaks in such versions. We'll probably have to introduce some BC breaks is our tidy. All our stream API is missing lots of features, and failing in many parts. We could as well add to the reflection Async I/O and scatter/gather, something I already thought about for PHP 7, but found no time nor motivation nor friend contributors to push to the level of quality we expect it for PHP. While beeing perfectly valid, fixing just one little problem among many others is not a durable solution for our stream API, which is old, patched everywhere, but pretty stable and serving its purpose as-is. There are lots of problems in extensions as well, regarding streams, where it is far from beeing easy to change one of the stream layer behavior, or implement your own. This should get addressed as well. Julien.Pauli