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
When compiling
@computecode 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
CallExpis a direct function call and unconditionally dereferencese->f. For indirect function calls,e->fis anullptr.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 invisit(CallExp *e)andisNonComputeCallExpVaild