Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Possible bug: Context deactivation mismatches #429

Open
maleadt opened this issue Jul 16, 2024 · 0 comments
Open

Possible bug: Context deactivation mismatches #429

maleadt opened this issue Jul 16, 2024 · 0 comments

Comments

@maleadt
Copy link
Owner

maleadt commented Jul 16, 2024

Triggering a diagnostic as part of a nested @dispose ctx=Context(), it seems possible to hit the wrong context destructor:

julia> @device_code_agx @metal identity(nothing)
; GPUCompiler.CompilerJob{GPUCompiler.MetalCompilerTarget, Metal.MetalCompilerParams}(MethodInstance for identity(::Nothing), CompilerConfig for GPUCompiler.MetalCompilerTarget, 0x0000000000007b77)

ERROR: Deactivating wrong context
Stacktrace:
  [1] error(s::String)
    @ Base ./error.jl:35
  [2] deactivate(ctx::LLVM.Context)
    @ LLVM ~/.julia/packages/LLVM/5DlHM/src/state.jl:31
  [3] JuliaContext(f::Metal.var"#146#154"{GPUCompiler.CompilerJob{GPUCompiler.MetalCompilerTarget, Metal.MetalCompilerParams}}; kwargs::@Kwargs{})
    @ GPUCompiler ~/.julia/packages/GPUCompiler/Y4hSX/src/driver.jl:54
  [4] JuliaContext(f::Function)
    @ GPUCompiler ~/.julia/packages/GPUCompiler/Y4hSX/src/driver.jl:42
  [5] macro expansion
    @ ~/Julia/pkg/Metal/src/compiler/compilation.jl:100 [inlined]
  [6] macro expansion
    @ ~/.julia/packages/ObjectiveC/uWFwg/src/os.jl:264 [inlined]
  [7] compile(job::GPUCompiler.CompilerJob)
    @ Metal ~/Julia/pkg/Metal/src/compiler/compilation.jl:98
  [8] actual_compilation(cache::Dict{…}, src::Core.MethodInstance, world::UInt64, cfg::GPUCompiler.CompilerConfig{…}, compiler::typeof(Metal.compile), linker::typeof(Metal.link))
    @ GPUCompiler ~/.julia/packages/GPUCompiler/Y4hSX/src/execution.jl:237
  [9] cached_compilation(cache::Dict{Any, Any}, src::Core.MethodInstance, cfg::GPUCompiler.CompilerConfig{GPUCompiler.MetalCompilerTarget, Metal.MetalCompilerParams}, compiler::Function, linker::Function)
    @ GPUCompiler ~/.julia/packages/GPUCompiler/Y4hSX/src/execution.jl:151
 [10] macro expansion
    @ ~/Julia/pkg/Metal/src/compiler/execution.jl:185 [inlined]
 [11] macro expansion
    @ ./lock.jl:267 [inlined]
 [12] mtlfunction(f::typeof(identity), tt::Type{Tuple{Nothing}}; name::Nothing, kwargs::@Kwargs{})
    @ Metal ~/Julia/pkg/Metal/src/compiler/execution.jl:180
 [13] mtlfunction(f::typeof(identity), tt::Type{Tuple{Nothing}})
    @ Metal ~/Julia/pkg/Metal/src/compiler/execution.jl:178
 [14] macro expansion
    @ ~/Julia/pkg/Metal/src/compiler/execution.jl:85 [inlined]
 [15] top-level scope
    @ ~/.julia/packages/GPUCompiler/Y4hSX/src/reflection.jl:206
 [16] top-level scope
    @ ~/Julia/pkg/Metal/src/initialization.jl:58

caused by: LLVM error: file doesn't start with bitcode header
Stacktrace:
 [1] handle_diagnostic(diag_ref::Ptr{LLVM.API.LLVMOpaqueDiagnosticInfo}, args::Ptr{Nothing})
   @ LLVM ~/.julia/packages/LLVM/5DlHM/src/core/context.jl:134
Some type information was truncated. Use `show(err)` to see complete types.

The offending code was:

    @dispose ctx=Context() metallib_module=parse(LLVM.Module, metallib_binary) begin
        @show metallib_module
    end

where the parse was triggering a diagnostic.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant