Skip to content

Severe memory consumption (20 GB+) when printing certain --trim errors #60412

@topolarity

Description

@topolarity

This is with a modified version of libsimple.jl:

module SimpleLib

struct CTree{T}
    children::Vector{CTree{T}}
end

Base.@ccallable "tree_size" function size(tree::CTree{Float64})::Int64
    children = tree.children
    length(children) != 0 && println(stderr, "bad time", children[1])
    # Return the size of this sub-tree
    return sum(Int[
        size(child)
        for child in children
    ]; init=1)
end

end

This triggers a severe over-consumption of memory:

$ ./julia ./contrib/juliac/juliac.jl --experimental --trim=safe test/trimming/libsimple.jl --output-lib libsimple.so --compile-ccallable
Error #1: <hangs here and rapidly exhausts memory>
[1777] signal 15: Terminated
in expression starting at none:0
unknown function (ip: 0x7d2d58b8950a) at /lib/x86_64-linux-gnu/libc.so.6
GenericMemory at ./boot.jl:615 [inlined]
array_new_memory at ./array.jl:1101 [inlined]
_growend_internal! at ./array.jl:1181
_growend! at ./array.jl:1205 [inlined]
_push! at ./array.jl:1348 [inlined]
push! at ./array.jl:1345 [inlined]
verify_create_stackframes at ./../usr/share/julia/Compiler/src/verifytrim.jl:269
verify_print_error at ./../usr/share/julia/Compiler/src/verifytrim.jl:234
verify_typeinf_trim at ./../usr/share/julia/Compiler/src/verifytrim.jl:511
unknown function (ip: 0x7d2d5092a640) at (unknown file)
_jl_invoke at /home/topolarity/repos/julia/src/gf.c:4116 [inlined]
ijl_apply_generic at /home/topolarity/repos/julia/src/gf.c:4313
jl_apply at /home/topolarity/repos/julia/src/julia.h:2285 [inlined]
jl_f_invoke_in_world at /home/topolarity/repos/julia/src/builtins.c:908
verify_typeinf_trim at ./../usr/share/julia/Compiler/src/typeinfer.jl:1838 [inlined]
typeinf_ext_toplevel at ./../usr/share/julia/Compiler/src/typeinfer.jl:1832
compile_and_emit_native at ./../usr/share/julia/Compiler/src/precompile.jl:415
jfptr_compile_and_emit_native_87134 at /home/topolarity/repos/julia/usr/lib/julia/sys.so (unknown line)
_jl_invoke at /home/topolarity/repos/julia/src/gf.c:4100 [inlined]
ijl_apply_generic at /home/topolarity/repos/julia/src/gf.c:4313
jl_apply at /home/topolarity/repos/julia/src/julia.h:2285 [inlined]
jl_create_native_impl at /home/topolarity/repos/julia/src/aotcompile.cpp:749
ijl_create_system_image at /home/topolarity/repos/julia/src/staticdata.c:3385
ijl_write_compiler_output at /home/topolarity/repos/julia/src/precompile.c:140
ijl_atexit_hook at /home/topolarity/repos/julia/src/init.c:280
jl_repl_entrypoint at /home/topolarity/repos/julia/src/jlapi.c:1139
main at /home/topolarity/repos/julia/cli/loader_exe.c:58
unknown function (ip: 0x7d2d58a2a1c9) at /lib/x86_64-linux-gnu/libc.so.6
__libc_start_main at /lib/x86_64-linux-gnu/libc.so.6 (unknown line)
_start at /home/topolarity/repos/julia/usr/bin/julia (unknown line)
unknown function (ip: (nil)) at (unknown file)
Allocations: 14933162 (Pool: 14933070; Big: 92); GC: 28

Failed to compile test/trimming/libsimple.jl

The OOM is so bad that it can knock me out of the WSL2 VM:

$ ./julia ./contrib/juliac/juliac.jl --experimental --trim=safe test/trimming/libsimple.jl --output-lib libsimple.so --compile-ccallable
Error #1<abruptly exits VM session>
PS C:\Users\topolarity> wsl
Catastrophic failure
Error code: Wsl/Service/E_UNEXPECTED
PS C:\Users\topolarity> wsl
Catastrophic failure
Error code: Wsl/Service/E_UNEXPECTED

Metadata

Metadata

Assignees

Labels

trimmingIssues with trimming functionality or PR's relevant to its performance/functionality

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions