llvm / llvm/llvm-project

[clang-c] using clang_getNullCursor from Java causes munmap_chunk(): invalid pointer on exit

Open
#184,046 2 comments 0 reactions 0 assignees View on GitHub
clang:as-a-library
Dominant language
LLVM
Stars
40.5k
Forks
18.7k
PR merge metrics
PR metrics pending

Description

Hi,

I'm making Java bindings for clang-c and have ran into an issue wherein using the `clang_getNullCursor` function will cause a `munmap_chunk(): invalid pointer` error on exit.

e.g:

```java
public class Test
{
public static void main(String[] args)
{
Index_h index = Index_h.INSTANCE;

CXCursor cursor = index.clang_getNullCursor();

NativeEnum32 kindField = cursor.getField(0);

System.out.println(kindField.get());

System.out.println(index.clang_isReference(CXCursorKind.CXCursor_ObjCSuperClassRef));
}
}
```

prints

```
CXCursor_FirstInvalid
1
munmap_chunk(): invalid pointer
```

If I comment out the clang-c `clang_getNullCursor` function call and related code, leaving only clang_isReference, this does not happen.

Is this some kind of bad interaction between clang-c and the JVM?

Clang Version is 21.1.8

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.