From b3741c01f2e2d4956be3ba41858c4065c6fbc7e8 Mon Sep 17 00:00:00 2001 From: Gabriel Baraldi Date: Thu, 7 Sep 2023 18:55:47 -0300 Subject: [PATCH] Check again if the tty is open inside the IO lock (#51222) This can cause segfaults when exiting julia. Co-authored-by: Valentin Churavy --- base/stream.jl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/base/stream.jl b/base/stream.jl index 0b6c9a93777f6..22af8d59359f3 100644 --- a/base/stream.jl +++ b/base/stream.jl @@ -565,7 +565,6 @@ displaysize() = (parse(Int, get(ENV, "LINES", "24")), parse(Int, get(ENV, "COLUMNS", "80")))::Tuple{Int, Int} function displaysize(io::TTY) - # A workaround for #34620 and #26687 (this still has the TOCTOU problem). check_open(io) local h::Int, w::Int @@ -588,6 +587,7 @@ function displaysize(io::TTY) s1 = Ref{Int32}(0) s2 = Ref{Int32}(0) iolock_begin() + check_open(io) Base.uv_error("size (TTY)", ccall(:uv_tty_get_winsize, Int32, (Ptr{Cvoid}, Ptr{Int32}, Ptr{Int32}), io, s1, s2) != 0)