Skip to content

Commit

Permalink
Fix gc_setmark size for strings (#20361)
Browse files Browse the repository at this point in the history
Fix #20360
  • Loading branch information
yuyichao authored and tkelman committed Feb 2, 2017
1 parent 8a2928f commit b0a3ff5
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/gc.c
Original file line number Diff line number Diff line change
Expand Up @@ -607,7 +607,7 @@ static inline uint16_t gc_setmark_pool(jl_ptls_t ptls, jl_taggedvalue_t *o,
}

static inline uint16_t gc_setmark(jl_ptls_t ptls, jl_value_t *v,
int sz, uintptr_t tag)
size_t sz, uintptr_t tag)
{
assert(!gc_marked(tag));
jl_taggedvalue_t *o = jl_astaggedvalue(v);
Expand Down
27 changes: 27 additions & 0 deletions test/core.jl
Original file line number Diff line number Diff line change
Expand Up @@ -4616,3 +4616,30 @@ end

# issue #19963
@test_nowarn ccall(:jl_free, Void, (Ptr{Void}, ), C_NULL)

# Wrong string size on 64bits for large string.
if Sys.WORD_SIZE == 64
@noinline function test_large_string20360(slot)
try
# Do no touch the string to avoid triggering OOM
slot[] = Base._string_n(2^32)
gc(false)
catch ex
# This can happen if there's a virtual address size limit
@test isa(ex, OutOfMemoryError)
@test_broken false
end
return
end
@noinline function tester20360()
gc()
# Makes sure the string is rooted during the `gc(false)`
# but is not before the last gc in this function.
slot = Ref{Any}()
test_large_string20360(slot)
slot[] = nothing
gc()
return
end
@test_nowarn tester20360()
end

0 comments on commit b0a3ff5

Please sign in to comment.