JuliaLang/julia

Bug in heapsnapshot generation for arrays of inlined objects

Open

#61396 opened on Mar 23, 2026

View on GitHub
 (5 comments) (0 reactions) (0 assignees)Julia (48,709 stars) (5,773 forks)batch import
GCgood first issueobservability

Description

Given an array like this:

julia> m = Memory{Pair{Any,Any}}([Pair{Any,Any}(1, 2), Pair{Any,Any}(3, 4)])
2-element Memory{Pair{Any, Any}}:
 1 => 2
 3 => 4

We will end up generating multiple lines with duplicate keys, which is not correct:

Src, Idx, Dst
  m,   1,   1
  m,   1,   2
  m,   2,   3
  m,   2,   4

Probably the right fix is to generate something like this instead:

Src,  Name, Dst
  m, [1].x,   1
  m, [1].y,   2
  m, [2].x,   3
  m, [2].y,   4

This would be fixed in the C++ code for generating the heapsnapshot, https://github.com/JuliaLang/julia/blob/8493b13f44455a5f16f1f830c223845a3dacf2c8/src/gc-heap-snapshot.cpp#L533-L537, and in the GC code that marks those edges, e.g. here: https://github.com/JuliaLang/julia/blob/8493b13f44455a5f16f1f830c223845a3dacf2c8/src/gc-stock.c#L2865-L2869

Contributor guide