Skip to content

Compiler segfaults in DComputeSemanticAnalyser on indirect function calls #5100

@Codingisinmyblud

Description

@Codingisinmyblud

When compiling @compute code that contains an indirect function call (such as a function pointer or delegate call), LDC crashes with a segmentation fault during the DCompute semantic validation pass.

The bug occurs in gen/semantic-dcompute.cpp within the DComputeSemanticAnalyser visitor.

The visitor assumes that every CallExp is a direct function call and unconditionally dereferences e->f. For indirect function calls, e->f is a nullptr.

In instances such as isNonComputeCallExpValid, the code immediately dereferences f without checking if it exists.

THis can also be seen in visit(CallExp *e), in if (e->f->ident == Id::criticalenter) the visitor unconditionally assumes e->f is a valid pointer.

A suggested fix would be to check if (e->f != nullptr) before accessing its members in visit(CallExp *e) and isNonComputeCallExpVaild

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions