NullReferenceException at VisitTypedefNameDecl

Open
#1,639 4 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
4/5
Estimated time
3-5 days
Newbie friendliness
38/100
Issue type
Bug
Clarity
Mostly clear
Activity status
Stale
Tech stack
cpp, csharp, linux

Research direction

Reproduce the MuJoCoSharp setup from the linked repository and start at CppSharp.AST.AstVisitor.VisitTypedefNameDecl, reached through ResolveIncompleteDeclsPass. Trace the typedef that triggers the NullReferenceException and use the existing stack trace and headers to identify the missing state; done means processing no longer crashes and the reported input is handled or diagnosed clearly.

Written by the indexing model from the issue text.

Description

Brief Description

I'm trying to create a wrapper for MuJoCo for c# in Linux. I've downloaded the library and its include files, and followed the Getting Started doc to create the setup below. I'm getting a NullReferenceException without any information about the offending source header code or how to solve it. Full code to reproduce the issue at https://github.com/emepetres/MuJoCoSharp

Setup:

            var includeFiles = Directory.GetFiles(@"[LIBPATH]/include");

            var options = driver.Options;
            options.Verbose = true;
            options.GeneratorKind = GeneratorKind.CSharp;
            var module = options.AddModule("MuJoCo");

            module.IncludeDirs.Add(@"[LIBPATH]/include");
            module.Headers.AddRange(includeFiles);

            module.LibraryDirs.Add(@"[LIBPATH]/bin");
            module.Libraries.Add("libmujoco210.so");

Linux (Manjaro, dotnet 5.0, CppSharp v1.0.0)

Used headers

MuJoCo include files at https://github.com/deepmind/mujoco/tree/main/include

Target: C#

Stack trace or incompilable generated code
Parsing libraries...
Parsed 'libmujoco210.so'
Parsing code...
Unhandled type class 'Complex'
Parsed '/home/jcarnero/source/MuJoCoSharp/build/mujoco210/include/mjrender.h, /home/jcarnero/source/MuJoCoSharp/build/mujoco210/include/glfw3.h, /home/jcarnero/source/MuJoCoSharp/build/mujoco210/include/mjui.h, /home/jcarnero/source/MuJoCoSharp/build/mujoco210/include/mjvisualize.h, /home/jcarnero/source/MuJoCoSharp/build/mujoco210/include/uitools.c, /home/jcarnero/source/MuJoCoSharp/build/mujoco210/include/mujoco.h, /home/jcarnero/source/MuJoCoSharp/build/mujoco210/include/mjdata.h, /home/jcarnero/source/MuJoCoSharp/build/mujoco210/include/mjxmacro.h, /home/jcarnero/source/MuJoCoSharp/build/mujoco210/include/uitools.h, /home/jcarnero/source/MuJoCoSharp/build/mujoco210/include/mjmodel.h'
Processing code...
Pass 'CppSharp.Passes.ResolveIncompleteDeclsPass'
Unhandled exception. System.NullReferenceException: Object reference not set to an instance of an object.
   at CppSharp.AST.AstVisitor.VisitTypedefNameDecl(TypedefNameDecl typedef)
   at CppSharp.AST.AstVisitor.VisitTypedefDecl(TypedefDecl typedef)
   at CppSharp.AST.TypedefDecl.Visit[T](IDeclVisitor`1 visitor)
   at CppSharp.AST.AstVisitor.VisitDeclarationContext(DeclarationContext context)
   at CppSharp.Passes.TranslationUnitPass.VisitTranslationUnit(TranslationUnit unit)
   at CppSharp.Passes.TranslationUnitPass.VisitASTContext(ASTContext context)
   at CppSharp.Passes.ResolveIncompleteDeclsPass.VisitASTContext(ASTContext c)
   at CppSharp.Generators.BindingContext.<RunPasses>b__37_0(TranslationUnitPass pass)
   at CppSharp.PassBuilder`1.RunPasses(Action`1 action)
   at CppSharp.Generators.BindingContext.RunPasses()
   at CppSharp.Driver.ProcessCode()
   at CppSharp.ConsoleDriver.Run(ILibrary library)
   at BindingGenerator.Program.Main(String[] args) in /home/jcarnero/source/MuJoCoSharp/src/BindingGenerator/Program.cs:line 12
Dominant language
C#
Stars
3.4k
Forks
541
PR merge metrics
No merged PRs in 30d

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from mono/CppSharp

All issues in mono/CppSharp

Similar issues

More C# issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.