Skip to content

Device capture guards miss pointer values stored in type parameters #755

Closed as not planned

Description

@jtravs

What happens

The internal ROCm capture guard rejects a raw Ptr, but accepts Val(pointer) and a closure carrying that value. Julia permits a pointer as a type parameter. The guard walks value fields, while Val{pointer} has no fields, so the captured pointer is never checked.

A closure can recover the exact pointer from its type parameter. It then has unowned storage with no verified context or lifetime, despite passing capture admission.

Reproduction

Host-only run on macOS arm64 with Julia 1.13.3 and pinned AMDGPU 2.11.0, against ROCm foundation commit 1a4d8aea80c0dd87dfc09ba5d5a052a64e2ec3d8:

import AMDGPU, SolpropJulia
E = Base.get_extension(SolpropJulia, :SolpropJuliaAMDGPUExt)
address = Ptr{Float32}(UInt(0x1000))
token = Val(address)
decode(::Val{P}) where {P} = P
body = let captured = token
    (row, column) -> decode(captured)
end

E._rocm_capture(address, nothing) # throws ArgumentError
E._rocm_capture(token, nothing)   # returns nothing
E._rocm_capture(body, nothing)    # returns nothing
body(1, 1) === address            # true

These admission outcomes were reproduced with the actual extension. No pointer was dereferenced, no kernel was launched, and no HIP runtime was available or called. The ROCm stride follow-up does not modify this guard.

The current CUDA and Metal helpers use the same field-only pattern: that is source-read evidence, not an executed cross-vendor reproduction.

Context

To do

  • Reject pointer values retained in captured type parameters, including nested tuples/parameter records.
  • Apply the same ownership rule consistently to each vendor guard without rejecting ordinary integer, floating-point, symbol or type metadata solely because it is parametrized.
  • Add actual-extension host admission regressions and preserve valid scalar-record/owned-array capture tests.
  • Keep initialized device execution and hardware qualification separate; this host check does not certify them.

Done when

The reproduced raw and parameter-hidden pointer cases both refuse before launch, valid non-pointer metadata remains admissible, and each changed vendor has focused host evidence. Record device checks actually run rather than converting hardware absence into a pass.

Activity

  1. added
    bugSomething isn't working
    priority: mediumReal work that should not wait long
    on Nov 11, 2026
  2. jtravs commented on Nov 11, 2026

    @jtravs
    ContributorAuthor

    Independent follow-up reproduced the same admission gap using the actual CUDA and Metal extensions on the host, with 14 assertions per vendor. Their execution source bytes match the currently integrated versions:

    • CUDA at dfa8f65603f488d5ccf6ed01bf599ed7377ba7c1, SHA256 ef5deaf29286892257964f9241730387228ad9b00749f67ba32c0a99cbb41fb6.
    • Metal at 035ee5ac9ca3e4be1f25d833c0227765acc0ab97, SHA256 24ad747baa1b112cd9a08a04b86ca578ee151021e48feaa71965406b5bc42430.

    The guards accept all five forms below (with ordinary Ptr{Float32}), although direct raw-pointer capture refuses:

    struct ParamCarrier{P} end
    struct PointerRecord
        address::Ptr{Float32}
    end
    address = Ptr{Float32}(UInt(0x1000))
    (
        Val(address),
        Val((address,)),
        ParamCarrier{address}(),
        Val(Tuple{Val{address}}),
        Val(PointerRecord(address)),
    )

    A closure retaining Val(address) also passes and recovers the original pointer from its parameter. Address-free positive controls (Val(:stage), Val(2), Val(Float32), Val(Ptr{Float32}), tuple tags and a parameter containing Tuple{Int,Float32}) pass. A pointer type alone carries no address and should not be rejected just because it is a type parameter.

    These were host admission tests only. No device allocation, kernel launch, pointer dereference, synchronization, or hardware arithmetic was performed. This strengthens the earlier source-read-only CUDA/Metal observation without claiming a device failure or device qualification.

  3. jtravs commented on Nov 12, 2026

    @jtravs
    ContributorAuthor

    Closing: the maintainer withdrew SEP 48 (the Julia backend) on 2026-11-11. C++/Kokkos stays the engine, and solprop has exactly two backends, native and numpy_ref (ADR-077, recorded in #763). This issue concerns only the Julia backend, its package, bridge or CI, so it no longer applies.

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingpriority: mediumReal work that should not wait long

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions