Skip to content

Commit

Permalink
fix #40773, bug in summarysize on arrays of inlined structs with po…
Browse files Browse the repository at this point in the history
…inters
  • Loading branch information
JeffBezanson committed Jul 6, 2021
1 parent 4733c00 commit 9434180
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
5 changes: 3 additions & 2 deletions base/summarysize.jl
Original file line number Diff line number Diff line change
Expand Up @@ -134,12 +134,13 @@ function (ss::SummarySize)(obj::Array)
if !haskey(ss.seen, datakey)
ss.seen[datakey] = true
dsize = Core.sizeof(obj)
if isbitsunion(eltype(obj))
T = eltype(obj)
if isbitsunion(T)
# add 1 union selector byte for each element
dsize += length(obj)
end
size += dsize
if !isempty(obj) && !Base.allocatedinline(eltype(obj))
if !isempty(obj) && (!Base.allocatedinline(T) || (T isa DataType && !Base.datatype_pointerfree(T)))
push!(ss.frontier_x, obj)
push!(ss.frontier_i, 1)
end
Expand Down
5 changes: 5 additions & 0 deletions test/misc.jl
Original file line number Diff line number Diff line change
Expand Up @@ -302,6 +302,11 @@ let vec = vcat(missing, ones(100000))
@test length(unique(summarysize(vec) for i = 1:20)) == 1
end

# issue #40773
let s = Set(1:100)
@test summarysize([s]) > summarysize(s)
end

# issue #13021
let ex = try
Main.x13021 = 0
Expand Down

0 comments on commit 9434180

Please sign in to comment.