You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
[release-1.10] dont reset maxsize in jl_array_to_string (#55689)
Let's change `jl_array_to_string` so that we make the consequences of
calling it in a thread-unsafe way less disastrous (i.e. let's avoid
corrupting GC internal metrics).
Strictly speaking, this is not a bug-fix because calling
`jl_array_to_string` concurrently from two threads is UB in any case.
To see how a race here may lead to negative `live_bytes`, consider this
MWE from @NHDaly:
- 1.10:
```Julia
julia> GC.gc(true); Base.gc_live_bytes()
1842370
julia> g_vecs = Any[
UInt8['a' for _ in 1:1000000000]
for _ in 1:10
];
julia> GC.gc(true); Base.gc_live_bytes()
10001774906
julia> Threads.@threads for _ in 1:1000
for v in g_vecs
String(v)
end
end
julia> GC.gc(true); Base.gc_live_bytes()
-1997600207
```
- This patch:
```Julia
julia> GC.gc(true); Base.gc_live_bytes()
1862440
julia> g_vecs = Any[
UInt8['a' for _ in 1:1000000000]
for _ in 1:10
];
julia> GC.gc(true); Base.gc_live_bytes()
10001796440
julia> Threads.@threads for _ in 1:1000
for v in g_vecs
String(v)
end
end
julia> GC.gc(true); Base.gc_live_bytes()
10002390952
```
0 commit comments