Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

segfault on a very large source file #29

Open
mmomtchev opened this issue Jul 26, 2023 · 2 comments
Open

segfault on a very large source file #29

mmomtchev opened this issue Jul 26, 2023 · 2 comments

Comments

@mmomtchev
Copy link

I get a segfault when trying to analyze this file: https://github.com/mmomtchev/node-magickwand/raw/84e1cdff82aae838233202e76b9ca01815e9ebec/Magick%2B%2B.cxx

I am using a very basic walking of the outermost members:

#include "cppparser/pub/cppparser.h"
#include <stdio.h>
#include <boost/filesystem.hpp>

namespace fs = boost::filesystem;

int main() {
  CppParser  parser;
  const auto testFilePath = fs::path(__FILE__).parent_path() / "Magick++.cxx";
  const auto ast          = parser.parseFile(testFilePath.string());

  const auto& members = ast->members();

  for (const auto &m : members) {
    if (m->objType_ == CppObjType::kFunction)
      printf("%s\n", ((CppFunctionEPtr)m)->name_.c_str());
  }
}

The output is:

Error: Unexpected 'SWIG_AddCast', while in context=ctxGeneral(1), found at line#383
SWIGINTERNINLINE int SWIG_AddCast
                     ^
Segmentation fault
@mmomtchev
Copy link
Author

I am trying to use the library to write a simple splitter that extracts all declarations in a single .h file and then splits the code definitions in multiple source files in order to bring down this huge codebase that has been generated by SWIG down to manageable levels.

@satya-das
Copy link
Owner

I don't see a seg fault with the latest code but I do get a parsing error.
The file uses macros to its extreme. The goal of cppparser is to allow parsing of all valid C++ files, but as of now handling of macros like this, which will need to do limited preprocessing before parsing, is not the priority.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants