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

clang_getCString returns garbage in lwjgl-llvm module #496

Closed
jolby opened this issue Aug 22, 2019 · 1 comment
Closed

clang_getCString returns garbage in lwjgl-llvm module #496

jolby opened this issue Aug 22, 2019 · 1 comment

Comments

@jolby
Copy link

jolby commented Aug 22, 2019

Environment

  • LWJGL version: 3.2.2
  • LWJGL build #: 10
  • Java version: OpenJDK 64-Bit Server VM v11.0.4+11-post-Debian-1bpo91 by Debian
  • Platform: Linux x86_64
  • Module: llvm

Description

The static method clang_getCString in ClangIndex in the llvm module returns garbage characters. I think that may because native clang_getCString expects a CXString struct passed as value, but lwjgl passes a Pointer/long address?? I'm not sure about that and I'm new to lwjgl.

I have attached a minimum test case illustrating the problem.
CXStringTest.java.txt

Note that the test case also shows you can properly get the String by getting the address of the first member of the CXString struct:

CXString cxstr = CXString.callocStack(stack);
//...
// VVVV--- This works
String cstr = memUTF8Safe(memGetAddress(cxstr.address()));
@Spasi
Copy link
Member

Spasi commented Aug 25, 2019

Thank you @jolby!

The Clang API is heavily used in the Template Extraction tool in LWJGL, but I never tested it on Linux. On Windows, >64bit structs are passed by pointer, so the bindings worked there correctly by accident.

fayer3 pushed a commit to fayer3/lwjgl3 that referenced this issue Jul 14, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants