Spooky tmux at a Distance: Difference between revisions

No edit summary
No edit summary
Line 53: Line 53:
}
}
</syntaxhighlight>
</syntaxhighlight>
the second parameter to <tt>term_emit()</tt> controlled flushery, and our third call flushes, and the world is good, right? well of course not--that <tt>term_emit()</tt> was conditional on <tt>nc->tcache.oc</tt>. and guess what terminal definition lacks <tt>oc</tt>? here's a hint: it starts with t and rhymes with "fucks". furthermore, <tt>term_emit()</tt> writes to <tt>nc->ttyfp</tt>, a stdio <tt>FILE*</tt>, while <tt>tty_emit()</tt> writes to a file descriptor, and requires actually being attached to a terminal (there's precious little value in, say, clearing the screen when you're writing to a file or pipe). so there are at least 4 bugs in these 14 lines. put another way, the only bug-free operative lines of code are <tt>int ret = 0;</tt>, <tt>ret = -1;</tt>, and <tt>return ret;</tt>.
dijkstra is looking down at me from Dutch heaven, frowning, slowly chewing a De Ruijter Fruit Sprinkle,  and saying "i do not like it."


so, to wrap everything up in one nice package:
so, to wrap everything up in one nice package:


* if the banners were used, they flushed stdio
* <tt>tmux</tt>, alone among tested terminals, did not declare <tt>oc</tt>. everything else flushed the reset early on, as intended, hiding the bug.
* a bug of mine meant that the reset was written using stdio, though admittedly this is merely a side-effect--the real bug was emitting control sequences to a non-terminal. this bug would otherwise not have been an issue, as <tt>write(2)</tt> is of course unbuffered.
* if the banners were used, they flushed stdout (by virtue of writing a newline), hiding the bug.
* stdout was not otherwise explicitly touched during the course of execution, but this unknown, supra-Standard behavior implied a buffer flush in an unrelated <tt>getc(3)</tt>.
* my previous fix did indeed address that limited case of the problem, changing a <tt>getc(3)</tt> to a <tt>read(2)</tt>, bypassing this behavior, and hiding the bug.
 
everything is not only broken, but broken several different ways. [https://arstechnica.com/gaming/2021/02/get-ready-to-feel-old-the-all-your-base-music-video-turns-20-today/ you have no chance to survice. make your time].