Repository navigation
fix(rrd): require a terminated status line when reading RRDtool pipe replies - #8659
somethingwithproof wants to merge 6 commits into
Conversation
b2294da to
3d697e7
Compare
cad1277 to
24f5f18
Compare
d303a0c to
b604c7e
Compare
TheWitness
left a comment
There was a problem hiding this comment.
Can this be tested on Windows?
b604c7e to
2a19de5
Compare
Partly, in b2f38d5. The end-of-reply check is now |
|
Native Windows results are now available from windows-2022 hosts with PHP 8.3.36/8.4.27 and the native UCRT64 RRDtool 1.11.0 executable. All 14 parser cases pass on each host. The real persistent-process test stalls and hits its three-minute watchdog on both versions. The same test also times out when only lib/rrd.php is replaced with the exact develop base (9235426). That establishes that the stall occurs without this parser change; it still blocks a Windows compatibility claim. Tracked as #8776, with the base control and logs: https://github.com/Cacti/cacti/actions/runs/44276696859 Linux Docker validation passed 58 process-safety tests (101 assertions) and five real-process integration tests (36 assertions). This PR remains blocked on the native Windows process-reader issue. |
c0b6c3b to
247aef9
Compare
247aef9 to
6555621
Compare
b4e69cb to
1630f27
Compare
1630f27 to
5d4738b
Compare
The persistent RRDtool pipe treated any read whose tail was "OK" or "ERROR:..." as the end of a reply, with no line anchor and no trailing newline. A read that stopped after PRINT text such as "BOOK", or inside image bytes that spell "OK", ended the reply early. The real status line was then read as the next command's reply, so every later command on that pipe was answered one step behind and a rejected update could be counted as written. Wait for RRDtool's actual terminator: a newline-terminated "OK u:..." (or bare "OK" on builds without getrusage) that is not preceded by a printable character, or an "ERROR:" line that starts a line. OK still matches directly after binary image data, which RRDtool writes with no newline before the status. The pipe-pressure test double now newline-terminates its text output the way RRDtool does. Signed-off-by: Thomas Vincent <thomasvincent@gmail.com>
The reply framing tests drove a /bin/sh double and were skipped on Windows. Move the status-line check into rrdtool_reply_status() so the framing decision itself is tested on every platform, including the reply shapes a native Windows build produces: binary-mode stdout ending in LF and a bare "OK" status, since that build has no getrusage. CRLF endings are covered as well. The matching rule is unchanged. Signed-off-by: Thomas Vincent <thomasvincent@gmail.com>
Signed-off-by: Thomas Vincent <thomasvincent@gmail.com>
Signed-off-by: Thomas Vincent <thomasvincent@gmail.com>
Signed-off-by: Thomas Vincent <thomasvincent@gmail.com>
Signed-off-by: Thomas Vincent <thomasvincent@gmail.com>
5d4738b to
af45d3c
Compare
|



On the persistent RRDtool pipe, the end-of-reply check (
lib/rrd.php) was not anchored: output ending in text such asPRINT:BOOK, or a PNG whose bytes happen to containOK, was taken as a finished reply, and the rest of the output was then read as the next command's reply.RRDtool ends every reply with
OK u:%1.2f s:%1.2f r:%1.2f\n(orOK\nwithout getrusage) or withERROR: ...\n, and for PNG outputOK u:follows the last image byte with no newline before it, so anchoringOKto a line start would break PNG graphs. The check now requires the status to end with a newline, rejectsOKonly when a printable character comes right before it, and requiresERROR:to start a line.Verification: two scripted fake-rrdtool cases (a
PRINT:BOOKreply followed by a failing command, andOKinside partial PNG data) fail before the fix; a third test drives real RRDtool 1.11 through create, update, a PNG graph with PRINT text,lastand a rejected update on one pipe.fake_rrdtool_argv.shnow ends text output with a newline like real RRDtool. RRD and Boost Pest suites 366 passed; PHPStan clean.Native Windows validation: 14 parser cases pass on both PHP 8.3 and 8.4 with RRDtool 1.11.0. The real persistent-process test times out on both the PR and the exact develop base, tracked in #8776. Windows compatibility remains blocked. Run and base control.
Ref #8776
Merge order: this PR and #8828 change tests/Unit/RrdProcessSafetyTest.php. Suggested order: this PR, then #8828. Whichever merges later will be rebased.