CppSharp icon indicating copy to clipboard operation
CppSharp copied to clipboard

Multiple "ConsoleDriver.Run"s causes AccessViolationException

Open caihongxu opened this issue 3 years ago • 2 comments

Brief Description

Adding two ConsoleDriver.Run() statements in the main function causes AccessViolationException. Keeping either one of them clears the exception.

OS: Windows 10.

Used settings

options.CheckSymbols = true;

Stack trace or incompilable generated code
Fatal error. System.AccessViolationException: Attempted to read or write protected memory. This is often an indication that other memory is corrupt.
Repeat 2 times:
--------------------------------
   at CppSharp.Parser.ClangParser+__Internal.Build(IntPtr, IntPtr, IntPtr, Boolean)
--------------------------------
   at CppSharp.Parser.ClangParser.Build(CppSharp.Parser.CppParserOptions, CppSharp.Parser.CppLinkerOptions, System.String, Boolean)
   at CppSharp.Passes.GenerateSymbolsPass.GenerateSymbols()
   at CppSharp.Passes.GenerateSymbolsPass.VisitASTContext(CppSharp.AST.ASTContext)
   at CppSharp.Generators.BindingContext.<RunPasses>b__37_0(CppSharp.Passes.TranslationUnitPass)
   at CppSharp.PassBuilder`1[[System.__Canon, System.Private.CoreLib, Version=6.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e]].RunPasses(System.Action`1<System.__Canon>)
   at CppSharp.Generators.BindingContext.RunPasses()
   at CppSharp.Driver.ProcessCode()
   at CppSharp.ConsoleDriver.Run(CppSharp.ILibrary)
   at Program.<Main>$(System.String[])

caihongxu avatar Jan 10 '22 05:01 caihongxu

Addressed by adding two modules instead of running two libraries.

caihongxu avatar Jan 10 '22 05:01 caihongxu

Using two modules works but it also means they have to share the same options.

Is there any way to process two libraries in one application?

caihongxu avatar Jan 11 '22 07:01 caihongxu