Bug #69290 [Opn->Fbk]: Invalid modes do not trigger errors

From: Date: Sat, 28 Mar 2015 11:39:55 +0000
Subject: Bug #69290 [Opn->Fbk]: Invalid modes do not trigger errors
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-191659@lists.php.net to get a copy of this message
Edit report at https://bugs.php.net/bug.php?id=69290&edit=1 ID: 69290 Updated by: ab@php.net Reported by: roborg at gmail dot com Summary: Invalid modes do not trigger errors -Status: Open +Status: Feedback Type: Bug Package: Program Execution Operating System: Windows PHP Version: 5.5.23 Block user comment: N Private report: N New Comment: @roborg thanks for the report. With the script hanging, I guess you're hitting the bug #51800 in 5.3 which was fixed in 5.5+ around last autumn. Pipe buffer on windows is way too small and can cause race conditions. Please check, if it's so - we can close this. Besides that, something standing in the comments is not the documentation, so it makes absolutely no sense to claim it a bug if it doesn't work. Thanks. Previous Comments: ------------------------------------------------------------------------ [2015-03-28 10:38:30] roborg at gmail dot com Status ------------------------------------------------------------------------ [2015-03-28 10:37:36] roborg at gmail dot com I've tested the script below with these results (sorry, I can't run these on the same OS): PHP: 5.3.5 OS: Win XP Mode: w Result: Script hangs PHP: 5.3.5 OS: Win XP Mode: a Result: Empty string PHP: 5.5.13 OS: Win 7 Mode: w Result: string 'x.......' PHP: 5.5.13 OS: Win 7 Mode: a Result: Empty string So the behavior has changed somewhat between 5.3 and 5.5, but not in the way I thought... It looks like the "a" mode never actually worked (as the output was empty), but just tricked PHP/Windows into not hanging. I still think failing silently is a really bad thing though. <?php $descriptors = array( array('pipe', 'r'), array('pipe', 'w'), array('pipe', 'w'), // This one changes between 'a' and 'w' ); $process = proc_open('c:\php\php.exe -r "$f = fopen(\'php://stderr\', \'w+\');fwrite($f, str_repeat(\'x\' . chr(10), 2048));', $descriptors, $pipes); var_dump(stream_get_contents($pipes[1])); var_dump(stream_get_contents($pipes[2])); proc_close($process); ------------------------------------------------------------------------ [2015-03-25 20:41:03] cmb@php.net This code has not been changed since 2003[1], so it's somewhat unlikely that a BC break has been introduced in PHP 5.x.y. If you can reproduce a behavioral change, please let us know (and change the bug status back to "Open"). [1] <https://github.com/php/php-src/commit/1a314027d3c388a19a06ac370fa08a46d474e1bd#diff-19f692ed5f75687fc7bc1929910e540fR337> ------------------------------------------------------------------------ [2015-03-25 17:27:58] roborg at gmail dot com I found the issue in my code because I was passing in "a" as recommended in http://php.net/proc_open#97012 and I wasn't getting any output. I'm pretty confident it used to work, so to me it seems BC has already been broken, as it's changed from working to failing silently - I'd rather it changed from working to giving an error (/warning/notice). ------------------------------------------------------------------------ [2015-03-25 09:29:53] laruence@php.net in proc_open: if (strncmp(Z_STRVAL_PP(zmode), "w", 1) != 0) { descriptors[ndesc].parentend = newpipe[1]; descriptors[ndesc].childend = newpipe[0]; descriptors[ndesc].mode |= DESC_PARENT_MODE_WRITE; } else { descriptors[ndesc].parentend = newpipe[0]; descriptors[ndesc].childend = newpipe[1]; } so, it's very clear why no notice was raised(assume "r" by default). considering bc issue, and not very helpful notices.... maybe change to a doc issue is better. ------------------------------------------------------------------------ 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=69290 -- Edit this bug report at https://bugs.php.net/bug.php?id=69290&edit=1

« previous php.bugs (#191659) next »