-
-
Notifications
You must be signed in to change notification settings - Fork 5.5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Remove
jl_getch()
to fix race condition in getpass()
We accidentally introduced a race condition in `getpass()` by having `jl_getch()` toggle terminal modes for each keystroke. Not only is this slower and wasteful, it allows the kernel to receive keystrokes within a TTY in canonical mode (where it replaces certain characters [0]) and then reads from the kernel buffer in non-canonical mode. This results in us reading a `0x00` when we expected a `0x04` in certain cases on CI, which breaks some of our tests. The fix is to switch the TTY into raw mode once, before we ever print the password prompt, which closes the race condition. To do this, we moved more code from C to Julia, and removed the `jl_getch()` export, instead providing `jl_termios_size()`. [0] https://github.com/torvalds/linux/blob/e35e5b6f695d241ffb1d223207da58a1fbcdff4b/drivers/tty/n_tty.c#L1318
- Loading branch information
1 parent
301b62a
commit f93e1c8
Showing
4 changed files
with
79 additions
and
38 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters