Skip to content

main fails to compile: duplicate nested 'namespace GraphFile' in cactus-graph/src/io.cpp (introduced by #794) #801

Open

Description

@guillermovillegas

main fails to compile: duplicate nested namespace GraphFile in cactus-graph/src/io.cpp (introduced by #794)

Summary

Commit 09cb35a (fix(graph): deduplicate shared mmap weight files across component graphs, #794) — the current HEAD of main — opens a second namespace GraphFile { at cactus-graph/src/io.cpp:899 while the one opened at line 692 is still open. The MappedFileRegistry member definitions that follow therefore land in GraphFile::GraphFile, which does not enclose the MappedFileRegistry declared in cactus_graph.h, and the file fails to compile with 13 errors. Any build from main is broken, including cactus build --apple / cactus benchmark device builds.

Reproduction

git clone https://github.com/cactus-compute/cactus && cd cactus   # HEAD = 09cb35a
clang++ -fsyntax-only -std=c++20 -Icactus-graph -Icactus-graph/src \
  -Icactus-kernels cactus-graph/src/io.cpp

Errors (Apple clang, Xcode 26.6, macOS 26.4.1 — 13 total)

src/io.cpp:901:32: error: cannot define or redeclare 'mutex_' here because namespace 'GraphFile' does not enclose namespace 'MappedFileRegistry'
src/io.cpp:902:80: error: cannot define or redeclare 'cache_' here because namespace 'GraphFile' does not enclose namespace 'MappedFileRegistry'
src/io.cpp:915:49: error: cannot define or redeclare 'get_or_load' here because namespace 'GraphFile' does not enclose namespace 'MappedFileRegistry'
src/io.cpp:916:42: error: use of undeclared identifier 'filename'
src/io.cpp:917:38: error: unknown type name 'mutex_'; did you mean 'std::mutex'?
src/io.cpp:918:15: error: use of undeclared identifier 'cache_'
src/io.cpp:919:15: error: use of undeclared identifier 'cache_'
src/io.cpp:924:10: error: redefinition of 'sp'
src/io.cpp:924:44: error: use of undeclared identifier 'filename'
src/io.cpp:925:5: error: use of undeclared identifier 'cache_'
src/io.cpp:929:26: error: cannot define or redeclare 'clear' here because namespace 'GraphFile' does not enclose namespace 'MappedFileRegistry'
src/io.cpp:930:38: error: unknown type name 'mutex_'; did you mean 'std::mutex'?
src/io.cpp:931:5: error: use of undeclared identifier 'cache_'

Cause

namespace GraphFile { opens at io.cpp:692 and again at io.cpp:899 (closing at 934 and 1182). The block added by #794 nests a second GraphFile inside the first. Fix: delete the inner namespace GraphFile { / matching } // namespace GraphFile pair (or move the registry block outside the first namespace).

Additional observation: runtime defect in the same change

After patching the namespace locally so main builds, the resulting engine crashes (SIGSEGV) at model load on an iPhone 15 Pro with the prebuilt LFM2-VL-450M cq4 bundle, while the identical setup built from the v2.1.0 tag runs correctly. #794 is the only engine-side change between v2.1.0 and main, so the new mmap-dedup path appears to have a runtime defect on iOS in addition to the compile break. Suggest reviewing/reverting #794 rather than only fixing the namespace.

Activity

  1. modelpath-dev commented on Sep 4, 2026

    @modelpath-dev

    I'll work on this. Could you assign it to me?

    I'll reproduce from the report, fix the failure path, and add a test so it stays fixed.

  2. modelpath-dev commented on Sep 6, 2026

    @modelpath-dev

    I am working on reproducing the issue and implementing the fix. I will update once I have made progress. Let me know if there are any specific tests you would like to see added.

  3. sorinstanila commented on Sep 6, 2026

    @sorinstanila

    The main build works after this change

    cactus/cactus-graph/src/io.cpp
      ⎿  Removed 2 lines
          896
          897  // MappedFileRegistry implementation
          898
          899 -namespace GraphFile {
          900 -
          899  std::mutex MappedFileRegistry::mutex_;
          900  std::unordered_map<std::string, std::weak_ptr<MappedFile>> MappedFileRegistry::cache_;
          901
    
    ⏺cactus/cactus-graph/src/io.cpp
      ⎿  Removed 2 lines
          929      cache_.clear();
          930  }
          931
          932 -} // namespace GraphFile
          933 -
          932  // MappedFile implementation
          933
          934  MappedFile::MappedFile(const std::string& filename)
    
    
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions