Skip to content

Commit a0fc853

Browse files
gbaraldivchuravy
authored andcommitted
Check again if the tty is open inside the IO lock (#51222)
This can cause segfaults when exiting julia. Co-authored-by: Valentin Churavy <[email protected]> (cherry picked from commit b3741c0)
1 parent e509c33 commit a0fc853

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

base/stream.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -565,7 +565,6 @@ displaysize() = (parse(Int, get(ENV, "LINES", "24")),
565565
parse(Int, get(ENV, "COLUMNS", "80")))::Tuple{Int, Int}
566566

567567
function displaysize(io::TTY)
568-
# A workaround for #34620 and #26687 (this still has the TOCTOU problem).
569568
check_open(io)
570569

571570
local h::Int, w::Int
@@ -588,6 +587,7 @@ function displaysize(io::TTY)
588587
s1 = Ref{Int32}(0)
589588
s2 = Ref{Int32}(0)
590589
iolock_begin()
590+
check_open(io)
591591
Base.uv_error("size (TTY)", ccall(:uv_tty_get_winsize,
592592
Int32, (Ptr{Cvoid}, Ptr{Int32}, Ptr{Int32}),
593593
io, s1, s2) != 0)

0 commit comments

Comments
 (0)