Skip to content

Conversation

@IanButterworth
Copy link
Member

Fixes #59406

               _
   _       _ _(_)_     |  Documentation: https://docs.julialang.org
  (_)     | (_) (_)    |
   _ _   _| |_  __ _   |  Type "?" for help, "]?" for Pkg help.
  | | | | | | |/ _` |  |
  | | |_| | | | (_| |  |  Version 1.13.0-DEV.1029 (2025-08-25)
 _/ |\__'_|_|_|\__'_|  |  ib/bad_history/ce2abad158* (fork: 1 commits, 5 days)
|__/                   |

ERROR: Invalid history file (/tmp/broken_history.jl) format:
If you have a history file left over from an older version of Julia,
try renaming or deleting it.
Invalid character: '{' at line 1
Stacktrace:
 [1] error(::String, ::String, ::String, ::Int64)
   @ Base ./error.jl:54
 [2] hist_from_file(hp::REPL.REPLHistoryProvider, path::String)
   @ REPL ~/Documents/GitHub/julia/usr/share/julia/stdlib/v1.13/REPL/src/REPL.jl:910
 [3] setup_interface(repl::LineEditREPL, hascolor::Bool, extra_repl_keymap::Any)
   @ REPL ~/Documents/GitHub/julia/usr/share/julia/stdlib/v1.13/REPL/src/REPL.jl:1410
 [4] setup_interface
   @ ~/Documents/GitHub/julia/usr/share/julia/stdlib/v1.13/REPL/src/REPL.jl:1281 [inlined]
 [5] run_frontend(repl::LineEditREPL, backend::REPL.REPLBackendRef)
   @ REPL ~/Documents/GitHub/julia/usr/share/julia/stdlib/v1.13/REPL/src/REPL.jl:1695
 [6] (::REPL.var"#61#62"{LineEditREPL, REPL.REPLBackendRef})()
   @ REPL ~/Documents/GitHub/julia/usr/share/julia/stdlib/v1.13/REPL/src/REPL.jl:678

[ Info: Disabling history file for this session
julia> 

@giordano giordano added REPL Julia's REPL (Read Eval Print Loop) bugfix This change fixes an existing bug backport 1.11 Change should be backported to release-1.11 backport 1.12 Change should be backported to release-1.12 labels Aug 27, 2025
@DilumAluthge
Copy link
Member

DilumAluthge commented Aug 28, 2025

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.

@DilumAluthge
Copy link
Member

DilumAluthge commented Aug 28, 2025

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.

@giordano
Copy link
Member

You need to start the REPL, no?

@DilumAluthge
Copy link
Member

Ah. I had naively thought that just running julia (with no other arguments) would have started a Julia REPL?

What arguments do I need to add in my Cmd to start a REPL?

@DilumAluthge
Copy link
Member

DilumAluthge commented Aug 28, 2025

julia -i doesn't seem to change anything; same for julia -i -e 'using REPL'.

@IanButterworth
Copy link
Member Author

Figured out the proper fix and added a test

@IanButterworth
Copy link
Member Author

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.

@IanButterworth IanButterworth added the merge me PR is reviewed. Merge when all tests are passing label Sep 3, 2025
@IanButterworth IanButterworth merged commit 6c02a21 into JuliaLang:master Sep 3, 2025
8 checks passed
@IanButterworth IanButterworth deleted the ib/bad_history branch September 3, 2025 20:58
@DilumAluthge
Copy link
Member

Thanks so much Ian.

Is this backportable to 1.11.x?

@DilumAluthge DilumAluthge removed the merge me PR is reviewed. Merge when all tests are passing label Sep 3, 2025
@DilumAluthge
Copy link
Member

Ugh disregard my comment, I didn't see it already has the backport labels.

KristofferC pushed a commit that referenced this pull request Sep 4, 2025
KristofferC pushed a commit that referenced this pull request Sep 4, 2025
DelveCI pushed a commit to RelationalAI/julia that referenced this pull request Sep 6, 2025
DelveCI pushed a commit to RelationalAI/julia that referenced this pull request Sep 7, 2025
DilumAluthge pushed a commit that referenced this pull request Sep 9, 2025
@DilumAluthge DilumAluthge mentioned this pull request Sep 9, 2025
59 tasks
@DilumAluthge DilumAluthge added backport 1.11 Change should be backported to release-1.11 and removed backport 1.11 Change should be backported to release-1.11 labels Sep 9, 2025
KristofferC pushed a commit that referenced this pull request Sep 15, 2025
KristofferC pushed a commit that referenced this pull request Sep 15, 2025
@KristofferC KristofferC removed the backport 1.12 Change should be backported to release-1.12 label Sep 17, 2025
DilumAluthge added a commit that referenced this pull request Nov 3, 2025
Backported PRs:
- [x] #57523 <!-- Remove usages of weak symbols -->
- [x] #58127 <!-- [DOC] Update installation docs: /downloads/ =>
/install/ -->
- [x] #58202 <!-- [release-1.11] malloc: use jl_get_current_task to fix
null check -->
- [x] #58554 <!-- remove workaround for controlling terminal behavior in
repl_cmd -->
- [x] #58584 <!-- Make `Ptr` values static-show w/ type-information -->
- [x] #59062 <!-- remove a testset from MMAP that might cause CI to now
fail on Windows -->
- [x] #59300 <!-- Update the developer docs to reflect the use of
JuliaSyntax.jl -->
- [x] #57604 <!-- `@nospecialize` for `string_index_err` -->
- [x] #59329 <!-- aotcompile: destroy LLVM context after serializing
combined module -->
- [x] #59418 <!-- Fix startup when history file is bad -->
- [x] #56890 <!-- Enable getting non-boxed LLVM type from Julia Type -->
- [x] #59559 <!-- codegen: mark write barrier field load as volatile -->
- [x] #59572 <!-- Only apply Base.Sort.SubArrayOptimization when
iszero(v.offset1) -->

Need manual backport:
- [ ] #56329 <!-- loading: clean up more concurrency issues -->
- [ ] #56956 <!-- Add "mea culpa" to foreign module assignment error.
-->
- [ ] #57035 <!-- linux: workaround to avoid deadlock inside
dl_iterate_phdr in glibc -->
- [ ] #57089 <!-- Block thread from receiving profile signal with
stackwalk lock -->
- [ ] #57249 <!-- restore non-freebsd-unix fix for profiling -->
- [ ] #58011 <!-- Remove try-finally scope from `@time_imports`
`@trace_compile` `@trace_dispatch` -->
- [ ] #58062 <!-- remove unnecessary edge from `exp_impl` to `pow` -->
- [ ] #58157 <!-- add showing a string to REPL precompile workload -->
- [ ] #58209 <!-- Specialize `one` for the `SizedArray` test helper -->
- [ ] #58356 <!-- codegen: remove readonly from abstract type calling
convention -->
- [ ] #58415 <!-- [REPL] more reliable extension loading -->
- [ ] #58510 <!-- Don't filter `Core` methods from newly-inferred list
-->
- [ ] #58110 <!-- relax dispatch for the `IteratorSize` method for
`Generator` -->
- [ ] #58965 <!-- Fix `hygienic-scope`s in inner macro expansions -->
- [ ] #58971 <!-- Fix alignment of failed precompile jobs on CI -->
- [ ] #59066 <!-- build: Also pass -fno-strict-aliasing for C++ -->
- [ ] #59428 <!-- Correctly set the variant bits of uuid1 -->

Contains multiple commits, manual intervention needed:
- [ ] #55877 <!-- fix FileWatching designs and add workaround for a stat
bug on Apple -->
- [ ] #56755 <!-- docs: fix scope type of a `struct` to hard -->
- [ ] #57809 <!-- Fix fptrunc Float64 -> Float16 rounding through
Float32 -->
- [ ] #57398 <!-- Make remaining float intrinsics require float
arguments -->
- [ ] #56351 <!-- Fix `--project=@script` when outside script directory
-->
- [ ] #57129 <!-- clarify that time_ns is monotonic -->
- [ ] #58134 <!-- Note annotated string API is experimental in Julia
1.11 in HISTORY.md -->
- [ ] #58401 <!-- check that hashing of types does not foreigncall
(`jl_type_hash` is concrete evaluated) -->
- [ ] #58435 <!-- Fix layout flags for types that have oddly sized
primitive type fields -->
- [ ] #58483 <!-- Fix tbaa usage when storing into heap allocated
immutable structs -->
- [ ] #58512 <!-- Make more types jl_static_show readably -->
- [ ] #58012 <!-- Re-enable tab completion of kwargs for large method
tables -->
- [ ] #58683 <!-- Add 0 predecessor to entry basic block and handle it
in inlining -->
- [ ] #59112 <!-- Add builtin function name to add methods error -->
- [ ] #56823 <!-- Make version of opaque closure constructor in world
-->
- [ ] #59467 <!-- `CoreLogging`: prevent some `Annotated*`-related
instability -->

Non-merged PRs with backport label:
- [ ] #59450 <!-- Propagate Addrspaces: fix lift of memset -->
- [ ] #58848 <!-- Set array size only when safe to do so -->
- [ ] #55958 <!-- also redirect JL_STDERR etc. when redirecting to
devnull -->
- [ ] #55956 <!-- Make threadcall gc safe -->
- [ ] #55534 <!-- Set stdlib sources as read-only during installation
-->
- [ ] #55499 <!-- propagate the terminal's `displaysize` to the
`IOContext` used by the REPL -->
- [ ] #55458 <!-- Allow for generically extracting unannotated string
-->
- [ ] #55457 <!-- Make AnnotateChar equality consider annotations -->
- [ ] #55220 <!-- `isfile_casesensitive` fixes on Windows -->
- [ ] #53957 <!-- tweak how filtering is done for what packages should
be precompiled -->
- [ ] #51479 <!-- prevent code loading from lookin in the versioned
environment when building Julia -->
- [ ] #50813 <!-- More doctests for Sockets and capitalization fix -->
- [ ] #50157 <!-- improve docs for `@inbounds` and
`Base.@propagate_inbounds` -->

---------

Co-authored-by: Dilum Aluthge <[email protected]>
Co-authored-by: Sam Schweigel <[email protected]>
Co-authored-by: Cody Tapscott <[email protected]>
Co-authored-by: Jameson Nash <[email protected]>
Co-authored-by: Adam Wheeler <[email protected]>
Co-authored-by: Neven Sajko <[email protected]>
Co-authored-by: Shuhei Kadowaki <[email protected]>
Co-authored-by: Ian Butterworth <[email protected]>
Co-authored-by: William Moses <[email protected]>
Co-authored-by: Valentin Churavy <[email protected]>
Co-authored-by: Lilith Orion Hafner <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

backport 1.11 Change should be backported to release-1.11 bugfix This change fixes an existing bug REPL Julia's REPL (Read Eval Print Loop)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Regression 1.11: Julia fails to start if history file is invalid (or unparseable)

4 participants