Skip to content

Assertion/hang precompiling code that calls inference with custom AbstractInterpreter #46296

@maleadt

Description

@maleadt

See #46296 (comment) for a MWE.


I was trying out SnoopPrecompile with CUDA.jl in an attempt to reduce TTFX, but doing so crashes Julia. I added the following to CUDA.jl's src/precompile.jl:

using SnoopPrecompile

@precompile_all_calls begin
    target = PTXCompilerTarget(; cap=v"7.0")
    params = CUDACompilerParams()
    job = CompilerJob(target, FunctionSpec(identity, Tuple{Nothing}, true), params)
    GPUCompiler.code_native(devnull, job)
end

On 1.8, this results in:

signal (11): Segmentation fault
in expression starting at none:1
jl_deserialize_value_singleton at /cache/build/default-amdci5-5/julialang/julia-release-1-dot-8/src/dump.c:1941 [inlined]
jl_deserialize_value at /cache/build/default-amdci5-5/julialang/julia-release-1-dot-8/src/dump.c:2160

From a cursory look, it's inspecting dt->instance while dt is null. Reproducing this doesn't require a GPU, CUDA.jl can precompile without, but in any case here's an rr recording: https://s3.amazonaws.com/julialang-dumps/reports/2022-08-09T15-39-40-maleadt.tar.zst

I wanted to cut-out CUDA and reproduce this on GPUCompiler with a debug build, but I'm getting a different error adding the following to GPUCompiler's src/precompile.jl:

using SnoopPrecompile

struct CUDACompilerParams <: AbstractCompilerParams end

@precompile_all_calls begin
    target = PTXCompilerTarget(; cap=v"7.0")
    params = CUDACompilerParams()
    job = CompilerJob(target, FunctionSpec(identity, Tuple{Nothing}, true), params)
    GPUCompiler.code_native(devnull, job)
end

i.e. the same but with a dummy CUDACompilerParams definition. Trying to precompile GPUCompiler on 1.8 hangs, on 1.9 with a debug build it results in:

julia-debug: /home/tim/Julia/src/julia/src/dump.c:2159: jl_deserialize_value: Assertion `offs < backref_list.len' failed.

Maybe this is the same error? Again, here's an rr trace: https://s3.amazonaws.com/julialang-dumps/reports/2022-08-09T15-34-52-maleadt.tar.zst

Metadata

Metadata

Assignees

Labels

bugIndicates an unexpected problem or unintended behaviorcompiler:precompilationPrecompilation of modules

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions