-
-
Notifications
You must be signed in to change notification settings - Fork 5.6k
Fix startup when history file is bad #59418
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix startup when history file is bad #59418
Conversation
Could we add a test? I tried to write one, but I can't figure out how to run Julia in a subprocess in a way that reproduces the bug. |
Just as an example of one thing I tried (super hacky, obviously, and almost certainly incorrect): histfile, hist_io = mktemp()
write(hist_io, UInt8[0xd0, 0x45, 0xc7]) # invalid history file contents
close(hist_io)
julia = Base.julia_cmd()[1]
cmd = addenv(`$julia`, "JULIA_HISTORY" => histfile);
io = open(cmd; write = true, read = true);
println(io, "101 + 202")
sleep(2)
bytes = read(io, 1)
append!(bytes, read(io, bytesavailable(io)))
str = String(copy(bytes))
@info "" str
# This will print:
# ┌ Info:
# └ str = "303\n" But this code doesn't seem to error on Julia 1.11, so I'm not able to actually reproduce the bug with this method. |
You need to start the REPL, no? |
Ah. I had naively thought that just running What arguments do I need to add in my |
|
2a14dd2
to
fec6bf8
Compare
Figured out the proper fix and added a test |
From the test failure I think the fix might not be working on Windows.. If someone can check on windows that would help. Otherwise I'll try to figure it out from the tests. |
Thanks so much Ian. Is this backportable to 1.11.x? |
Ugh disregard my comment, I didn't see it already has the backport labels. |
(cherry picked from commit 6c02a21)
(cherry picked from commit 6c02a21)
(cherry picked from commit 6c02a21)
(cherry picked from commit 6c02a21)
(cherry picked from commit 6c02a21)
(cherry picked from commit 6c02a21)
(cherry picked from commit 6c02a21)
Fixes #59406