Skip to content

[Bug] hwdec_cuda_gl: Extra cuCtxPopCurrent causing CUDA context stack underflow #17988

@hklcf

Description

@hklcf

File

video/out/hwdec/hwdec_cuda_gl.c:87

Description

Extra cuCtxPopCurrent causing CUDA context stack underflow. cuda_ext_gl_init pops the CUDA context in its error path, but the caller (mapper_init in hwdec_cuda.c) already manages the context push/pop:

In hwdec_cuda_gl.c:87 (error path of cuda_ext_gl_init):

error:
    CHECK_CU(cu->cuCtxPopCurrent(&dummy));  // pop #1
    return false;

In hwdec_cuda.c:191,201 (caller):

CHECK_CU(cu->cuCtxPushCurrent(p->display_ctx));  // push
for (...) {
    if (!p_owner->ext_init(...))  // calls cuda_ext_gl_init
        goto error;
}
error:
    CHECK_CU(cu->cuCtxPopCurrent(&dummy));  // pop #2 - double pop!

Why It's a Bug

The caller pushes the context once and expects exactly one pop. The callee (cuda_ext_gl_init) pops it on error, and the caller also pops it, causing a CUDA context stack underflow. This can corrupt CUDA driver state and crash subsequent CUDA operations.

Suggested Fix

Remove the cuCtxPopCurrent from cuda_ext_gl_init's error path (line 87). The caller handles the context management.

Severity

Major

Metadata

Metadata

Assignees

No one assigned

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions