kaimon crash report #29

Closed
opened 2026-04-22 11:39:54 -07:00 by haakon-e · 2 comments
haakon-e commented 2026-04-22 11:39:54 -07:00 (Migrated from github.com)

Kaimon v1.3.1, installed as an app.

Didn't do anything spectacular at the time, to my knowledge. Claude had just submitted some julia code to a repl session with ex.
Crash report:

StringIndexError: invalid index [45], valid nearby indices [44]=>'—', [47]=>' '
Stacktrace:
  [1] string_index_err(s::AbstractString, i::Int64)
    @ Base ./strings/string.jl:12
  [2] getindex(s::String, r::UnitRange{Int64})
    @ Base ./strings/string.jl:503
  [3] render(dt::Tachikoma.DataTable, rect::Tachikoma.Rect, buf::Tachikoma.Buffer)
    @ Tachikoma ~/.julia/packages/Tachikoma/vrBon/src/widgets/datatable.jl:534
  [4] view_activity(m::Kaimon.KaimonModel, area::Tachikoma.Rect, buf::Tachikoma.Buffer)
    @ Kaimon ~/.julia/packages/Kaimon/6N7iB/src/tui/activity.jl:565
  [5] view(m::Kaimon.KaimonModel, f::Tachikoma.Frame)
    @ Kaimon ~/.julia/packages/Kaimon/6N7iB/src/tui/view.jl:350
  [6] (::Tachikoma.var"#241#242"{Tachikoma.Frame, Tachikoma.AppOverlay, Bool, Kaimon.KaimonModel})()
    @ Tachikoma ~/.julia/packages/Tachikoma/vrBon/src/app.jl:1111
  [7] #239
    @ ~/.julia/packages/Tachikoma/vrBon/src/app.jl:1107 [inlined]
  [8] draw!(func::Tachikoma.var"#239#240"{Tachikoma.AppOverlay, Bool, Kaimon.KaimonModel}, t::Tachikoma.Terminal)
    @ Tachikoma ~/.julia/packages/Tachikoma/vrBon/src/terminal.jl:926
  [9] (::Tachikoma.var"#229#230"{Int64, Bool, Kaimon.KaimonModel, Base.RefValue{Any}, Base.RefValue{Any}, Base.RefValue{Bool}})(t::Tachikoma.Terminal)
    @ Tachikoma ~/.julia/packages/Tachikoma/vrBon/src/app.jl:1106
 [10] with_terminal(f::Tachikoma.var"#229#230"{Int64, Bool, Kaimon.KaimonModel, Base.RefValue{Any}, Base.RefValue{Any}, Base.RefValue{Bool}}; tty_out::Nothing, tty_size::Nothing, on_stdout::Nothing, on_stderr::Nothing)
    @ Tachikoma ~/.julia/packages/Tachikoma/vrBon/src/terminal.jl:1515
 [11] with_terminal
    @ ~/.julia/packages/Tachikoma/vrBon/src/terminal.jl:1493 [inlined]
 [12] app(model::Kaimon.KaimonModel; fps::Int64, default_bindings::Bool, on_stdout::Nothing, on_stderr::Nothing, tty_out::Nothing, tty_size::Nothing)
    @ Tachikoma ~/.julia/packages/Tachikoma/vrBon/src/app.jl:1010
 [13] invokelatest
    @ ./Base_compiler.jl:250 [inlined]
 [14] tui(; port::Int64, theme_name::Nothing, revise_polling::Bool, revise_mod::Nothing)
    @ Kaimon ~/.julia/packages/Kaimon/6N7iB/src/tui/lifecycle.jl:440
 [15] main(ARGS::Vector{String})
    @ Kaimon ~/.julia/packages/Kaimon/6N7iB/src/Kaimon.jl:2657
 [16] _start()
    @ Base ./client.jl:556
ERROR: StringIndexError: invalid index [45], valid nearby indices [44]=>'—', [47]=>' '
Stacktrace:
 [1] app(model::Kaimon.KaimonModel; fps::Int64, default_bindings::Bool, on_stdout::Nothing, on_stderr::Nothing, tty_out::Nothing, tty_size::Nothing)
   @ Tachikoma ~/.julia/packages/Tachikoma/vrBon/src/app.jl:1159
 [2] invokelatest
   @ ./Base_compiler.jl:250 [inlined]
 [3] tui(; port::Int64, theme_name::Nothing, revise_polling::Bool, revise_mod::Nothing)
   @ Kaimon ~/.julia/packages/Kaimon/6N7iB/src/tui/lifecycle.jl:440
 [4] main(ARGS::Vector{String})
   @ Kaimon ~/.julia/packages/Kaimon/6N7iB/src/Kaimon.jl:2657
 [5] _start()
   @ Base ./client.jl:556
Kaimon v1.3.1, installed as an app. Didn't do anything spectacular at the time, to my knowledge. Claude had just submitted some julia code to a repl session with `ex`. Crash report: ```julia StringIndexError: invalid index [45], valid nearby indices [44]=>'—', [47]=>' ' Stacktrace: [1] string_index_err(s::AbstractString, i::Int64) @ Base ./strings/string.jl:12 [2] getindex(s::String, r::UnitRange{Int64}) @ Base ./strings/string.jl:503 [3] render(dt::Tachikoma.DataTable, rect::Tachikoma.Rect, buf::Tachikoma.Buffer) @ Tachikoma ~/.julia/packages/Tachikoma/vrBon/src/widgets/datatable.jl:534 [4] view_activity(m::Kaimon.KaimonModel, area::Tachikoma.Rect, buf::Tachikoma.Buffer) @ Kaimon ~/.julia/packages/Kaimon/6N7iB/src/tui/activity.jl:565 [5] view(m::Kaimon.KaimonModel, f::Tachikoma.Frame) @ Kaimon ~/.julia/packages/Kaimon/6N7iB/src/tui/view.jl:350 [6] (::Tachikoma.var"#241#242"{Tachikoma.Frame, Tachikoma.AppOverlay, Bool, Kaimon.KaimonModel})() @ Tachikoma ~/.julia/packages/Tachikoma/vrBon/src/app.jl:1111 [7] #239 @ ~/.julia/packages/Tachikoma/vrBon/src/app.jl:1107 [inlined] [8] draw!(func::Tachikoma.var"#239#240"{Tachikoma.AppOverlay, Bool, Kaimon.KaimonModel}, t::Tachikoma.Terminal) @ Tachikoma ~/.julia/packages/Tachikoma/vrBon/src/terminal.jl:926 [9] (::Tachikoma.var"#229#230"{Int64, Bool, Kaimon.KaimonModel, Base.RefValue{Any}, Base.RefValue{Any}, Base.RefValue{Bool}})(t::Tachikoma.Terminal) @ Tachikoma ~/.julia/packages/Tachikoma/vrBon/src/app.jl:1106 [10] with_terminal(f::Tachikoma.var"#229#230"{Int64, Bool, Kaimon.KaimonModel, Base.RefValue{Any}, Base.RefValue{Any}, Base.RefValue{Bool}}; tty_out::Nothing, tty_size::Nothing, on_stdout::Nothing, on_stderr::Nothing) @ Tachikoma ~/.julia/packages/Tachikoma/vrBon/src/terminal.jl:1515 [11] with_terminal @ ~/.julia/packages/Tachikoma/vrBon/src/terminal.jl:1493 [inlined] [12] app(model::Kaimon.KaimonModel; fps::Int64, default_bindings::Bool, on_stdout::Nothing, on_stderr::Nothing, tty_out::Nothing, tty_size::Nothing) @ Tachikoma ~/.julia/packages/Tachikoma/vrBon/src/app.jl:1010 [13] invokelatest @ ./Base_compiler.jl:250 [inlined] [14] tui(; port::Int64, theme_name::Nothing, revise_polling::Bool, revise_mod::Nothing) @ Kaimon ~/.julia/packages/Kaimon/6N7iB/src/tui/lifecycle.jl:440 [15] main(ARGS::Vector{String}) @ Kaimon ~/.julia/packages/Kaimon/6N7iB/src/Kaimon.jl:2657 [16] _start() @ Base ./client.jl:556 ERROR: StringIndexError: invalid index [45], valid nearby indices [44]=>'—', [47]=>' ' Stacktrace: [1] app(model::Kaimon.KaimonModel; fps::Int64, default_bindings::Bool, on_stdout::Nothing, on_stderr::Nothing, tty_out::Nothing, tty_size::Nothing) @ Tachikoma ~/.julia/packages/Tachikoma/vrBon/src/app.jl:1159 [2] invokelatest @ ./Base_compiler.jl:250 [inlined] [3] tui(; port::Int64, theme_name::Nothing, revise_polling::Bool, revise_mod::Nothing) @ Kaimon ~/.julia/packages/Kaimon/6N7iB/src/tui/lifecycle.jl:440 [4] main(ARGS::Vector{String}) @ Kaimon ~/.julia/packages/Kaimon/6N7iB/src/Kaimon.jl:2657 [5] _start() @ Base ./client.jl:556 ```
kahliburke commented 2026-06-19 16:39:43 -07:00 (Migrated from github.com)

Root cause found — this is a UTF-8 byte-vs-character slicing bug in Tachikoma's DataTable.render, triggered when a cell (or header) that needs truncation contains a multi-byte character. Your crash index [45] landing next to [44]=>'—' is the tell: (em-dash) is 3 bytes, and the truncation slices mid-character.

Two spots in Tachikoma.jl/src/widgets/datatable.jl:

  • Cells (~line 534):
    if length(cell_text) > avail
        cell_text = avail > 1 ? cell_text[1:max(1, avail-1)] * "…" : string(cell_text[1])
    end
    
  • Headers (~line 435):
    hdr[1:min(end, w)]
    

length(cell_text) counts characters, but cell_text[1:n] indexes by bytes — so when n falls inside a multi-byte char, getindex(::String, ::UnitRange) throws StringIndexError.

Fix: use Base.first(s, n), which truncates by character count (and clamps when n ≥ length):

# cells
cell_text = avail > 1 ? first(cell_text, max(1, avail-1)) * "…" : string(first(cell_text, 1))
# headers
first(hdr, w)

Both are crash-safe and match the character-count intent already used by the surrounding length(...) checks. (For full correctness with wide/CJK glyphs, textwidth-based truncation would be the larger follow-up, but first resolves the crash.)

This lives in Tachikoma, so the fix belongs there; leaving this open until it lands. A good regression test: render a DataTable whose cell/header contains (or any non-ASCII char) in a column narrow enough to force truncation.

Root cause found — this is a UTF-8 byte-vs-character slicing bug in Tachikoma's `DataTable.render`, triggered when a cell (or header) that needs truncation contains a multi-byte character. Your crash index `[45]` landing next to `[44]=>'—'` is the tell: `—` (em-dash) is 3 bytes, and the truncation slices mid-character. Two spots in `Tachikoma.jl/src/widgets/datatable.jl`: - **Cells (~line 534):** ```julia if length(cell_text) > avail cell_text = avail > 1 ? cell_text[1:max(1, avail-1)] * "…" : string(cell_text[1]) end ``` - **Headers (~line 435):** ```julia hdr[1:min(end, w)] ``` `length(cell_text)` counts **characters**, but `cell_text[1:n]` indexes by **bytes** — so when `n` falls inside a multi-byte char, `getindex(::String, ::UnitRange)` throws `StringIndexError`. **Fix:** use `Base.first(s, n)`, which truncates by character count (and clamps when `n ≥ length`): ```julia # cells cell_text = avail > 1 ? first(cell_text, max(1, avail-1)) * "…" : string(first(cell_text, 1)) # headers first(hdr, w) ``` Both are crash-safe and match the character-count intent already used by the surrounding `length(...)` checks. (For full correctness with wide/CJK glyphs, `textwidth`-based truncation would be the larger follow-up, but `first` resolves the crash.) This lives in Tachikoma, so the fix belongs there; leaving this open until it lands. A good regression test: render a `DataTable` whose cell/header contains `—` (or any non-ASCII char) in a column narrow enough to force truncation.
kahliburke commented 2026-06-19 16:47:04 -07:00 (Migrated from github.com)

Confirmed this is a Tachikoma-side bug (UTF-8 byte-slicing in DataTable.render, detailed above), not a Kaimon issue per se. Tracking the fix in Tachikoma: kahliburke/Tachikoma.jl#36.

Closing here; the crash will be resolved once that lands and Kaimon picks up the new Tachikoma.

Confirmed this is a Tachikoma-side bug (UTF-8 byte-slicing in `DataTable.render`, detailed above), not a Kaimon issue per se. Tracking the fix in Tachikoma: kahliburke/Tachikoma.jl#36. Closing here; the crash will be resolved once that lands and Kaimon picks up the new Tachikoma.
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
kahliburke/Kaimon.jl#29
No description provided.