Skip to content

Segmentation fault on macOS ARM64 with Clang 19 #37

@firilisinof

Description

@firilisinof

Environment

  • OS: macOS (Apple Silicon / ARM64)
  • Compiler: Clang 19.1.7 (LLVM)
  • PajeNG version: 1.3.10
  • Build system: CMake

Problem Description

I was following the SimGrid tutorials and when I tried to use PajeNG it crashed with a segmentation fault (Trace/BPT trap: 5) when attempting to read the trace file. The crash occurs in both:

  • Command-line tool pj_dump.
  • R package pajengr when calling pajeng_read().

Here's the shell output:

$ nix-shell --run "pj_dump master-tuto/simgrid.trace"
Container, 0, 0, 0, 5.13385, 5.13385, 0
Link, 0, 0-LINK6-LINK6, 0.000000, 0.000000, 0.000000, topology, 2, 0, 0
...
State, master-1, ACTOR_STATE, 4.965689, 5.133855, 0.168166, 0.000000, send
/private/tmp/nix-shell-73250-2590410299/rc, linha 3: 73258 Trace/BPT trap: 5          pj_dump master-tuto/simgrid.trace

During compilation, the following warnings appear:

/source/src/libpaje/PajeContainer.cc:62:7: warning: delete called on 'PajeEntity' that is abstract but has
 non-virtual destructor [-Wdelete-abstract-non-virtual-dtor]
   62 |       delete *entity;
      |       ^

/source/src/libpaje/PajeContainer.cc:851:9: warning: delete called on 'PajeEntity' that is abstract but
has non-virtual destructor [-Wdelete-abstract-non-virtual-dtor]
  851 |         delete child;
      |         ^

/source/src/libpaje/PajeSimulator+Queries.cc:168:20: warning: object backing the pointer will be destroyed
 at the end of the full-expression [-Wdangling-gsl]
  168 |     for (auto it = catType->values().begin(); it != catType->values().end(); ++it)
      |                    ^~~~~~~~~~~~~~~~~

The PajeEntity class (line 80 in src/libpaje/PajeEntity.h) has a non-virtual destructor, causing undefined behavior when deleting derived objects through base pointers. In src/libpaje/PajeSimulator+Queries.cc:168, iterating directly over a temporary container returned by values() creates dangling iterators.

My guess is that newer versions of Clang/LLVM are more aggressive with optimizations and more strict about diagnosing undefined behavior. Optimizations can rely on language rules (including UB) and thus generate code that causes immediate crashes where older compilers were (by chance) tolerant.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions