Skip to content

CGCollector segfaults in addCalledDecl, if caller is null #10

@sebastiankreutzer

Description

@sebastiankreutzer

I ran into a segfault when trying to run CGCollector on a simple test case:

#include <vector>
#include <iostream>

int main(int argc, char** argv) {
  std::vector<int> v;
  v.push_back(argc);

  std::cout << "Hello world!" << std::endl;
  return 0;
}

Invocation: cgcollector --capture-ctors-dtors --extra-arg=-I/opt/modules/packages/llvm/devel-xray-dso/lib/clang/20/include --metacg-format-version=2 /home/sebastian/git/capi/test/selection/artificial/02_stdheader_incl.cpp

Here is the relevant part of the stack trace:

Program received signal SIGSEGV, Segmentation fault.
CGBuilder::addCalledDecl (this=this@entry=0x7fffffffc1b8, Caller=Caller@entry=0x0, Callee=0xe8ec90, C=C@entry=0x0) at /home/sebastian/git/MetaCG-Gitlab/cgcollector/lib/src/CallGraph.cpp:789
warning: Source file is more recent than executable.
789	    if (!CallGraph::includeInGraph(Caller) || !CallGraph::includeInGraph(Callee))
(gdb) bt
#0  CGBuilder::addCalledDecl (this=this@entry=0x7fffffffc1b8, Caller=Caller@entry=0x0, Callee=0xe8ec90, C=C@entry=0x0) at /home/sebastian/git/MetaCG-Gitlab/cgcollector/lib/src/CallGraph.cpp:789
#1  0x00007ffff4d97ca8 in CGBuilder::VisitLambdaExpr (this=0x7fffffffc1b8, LE=0xe8fa20) at /home/sebastian/git/MetaCG-Gitlab/cgcollector/lib/src/CallGraph.cpp:960

I should note that this is with Clang 20, which we don't officially support yet.
Putting this here so that we can fix it a later time. I haven't tried with CGC2 yet.

Metadata

Metadata

Assignees

Labels

No labels
No labels

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