Skip to content

Commit

Permalink
Check again if the tty is open inside the IO lock (#51222)
Browse files Browse the repository at this point in the history
This can cause segfaults when exiting julia.

Co-authored-by: Valentin Churavy <vchuravy@users.noreply.github.com>
(cherry picked from commit b3741c0)
  • Loading branch information
gbaraldi authored and KristofferC committed Oct 11, 2023
1 parent ddb4a95 commit 4a81944
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion base/stream.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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)
Expand Down

0 comments on commit 4a81944

Please sign in to comment.