tcgetattr / tcsetattr seemingly behaving weirdly when piping output from VM into less and quitting #36453
Labels
area-core-library
SDK core library issues (core, async, ...); use area-vm or area-web for platform specific libraries.
library-io
P2
A bug or feature request we're likely to work on
type-bug
Incorrect behavior (everything from a crash to more subtle misbehavior)
On my machine at least, doing this:
out/ReleaseX64/dart pkg/kernel/bin/dump.dart out/ReleaseX64/vm_platform_strong.dill 2>stderrstuff | less
and immediately (as soon as
less
actually appears) typingq
to quitless
, my terminal becomes unresponsive (i.e. it doesn't echo what I type).Applying a patch like this
yields
in the file
stderrstuff
.If I instead just had run
out/ReleaseX64/dart hello.dart
the output is(according to calls to
stty -a
in both cases, it seems to beICANON
,ECHO
,ECHOE
andECHOK
missing in the case where the terminal becomes unresponsive).If I remove the call to
tcsetattr
the problem goes way (though this isn't a real solution).So it seems that
tcgetattr
gives a "wrong" result somehow.Interestingly enough, if I go to the end of the
less
input (G
) before quitting (q
) the problem goes away too, despite that the content ofstderrstuff
still being the same.My guess as to what happens is this:
less
sets-ICANON
,-ECHO
,-ECHOE
,-ECHOK
beforedart
callstcgetattr
less
goes to the end (and thedart
process shuts down (it doesn't appear to shut down beforeless
goes to the end)) before quittingless
,dart
sets the wrong stuff, butless
(once it quit) sets the right stuff. Result in this case: Everything is fine.less
is quit before going to the end,less
quits and sets the right stuff beforedart
quits and sets the wrong stuff. Result in this case: Terminal becomes unresponsive.So, said another way, my guess is that this is basically a kind of race condition between
dart
andless
://cc @mraleph any ideas or ideas of who to ping on this?
The text was updated successfully, but these errors were encountered: