graal icon indicating copy to clipboard operation
graal copied to clipboard

Exception when using @CFunction on Windows

Open Montura opened this issue 2 years ago • 1 comments

Describe the issue

There is a problem with calling native code corresponing the java functuion annotated @CFunction on Windows platform.

Accrording to CInterfaceTutorial.java and the cinterfecetutorail.c

@CContext(NativeTest.CApiDirectives.class)
public class NativeTest {

  static class CApiDirectives implements CContext.Directives { ...}
  
  @CFunction
  public native static int testC();
}
extern "C" int testC();

int main() {
  testC(); // crashes with exception on Windows
}

Steps to reproduce the issue Please include both build steps as well as run steps

  1. Use GraalVM CE Build v22.1.0 on Apr 26
  2. git clone https://github.com/Montura/graal-native-test
  3. https://github.com/Montura/graal-native-test#steps-to-reproduce

Describe GraalVM and your environment:

  • GraalVM version release v22.1.0
  • JDK major version: 11
  • OS and arch:
    • os: Windows 10 Pro 19044.1826, arch: x64 (Intel Core i3-8100)
    • os: Linux Ubuntu 20.04.4 LTS, arch: x64 (Intel Core i5-2410M)
    • os: Mac OS Big Sur Version 11.5.2, arch: x64 (Intel Core i9)

More details

  • on Linux and Mac Os works fine:
Expected output (digits are not valuable):
OS name: mac os
JNI time = 20
C time = 6
dummy time = 6
native time = 1
  • on Windows
Actual output (digits are not valuable):
OS name: windows 10
JNI time = 20

"Exception thrown at 0x00007FFA0F6F0000 (GraalSample.dll) in native.exe: 0xC0000005: Access violation executing location 0x00007FFA0F6F0000."

image

Possible cause

Montura avatar Jul 26 '22 14:07 Montura

Thank you for reporting this, we will take a look into it and get back to you

oubidar-Abderrahim avatar Aug 01 '22 14:08 oubidar-Abderrahim

@oubidar-Abderrahim, hello. Do you have any updates?

Montura avatar Aug 26 '22 07:08 Montura

I apologize for the super late response, the issue got buried under many others. Could you please verify if this issue is still present in our latest build of 22.3.0?

oubidar-Abderrahim avatar Jan 10 '23 14:01 oubidar-Abderrahim

If this issue is still relevant in the latest GraalVM versions, please create a new issue for it and follow the template provided. Thank you

oubidar-Abderrahim avatar Jan 16 '24 11:01 oubidar-Abderrahim

If this issue is still relevant in the latest GraalVM versions, please create a new issue for it and follow the template provided. Thank you

It's irrelevant, there is an issue with shared library linkage on Windows. dll export undefined symbols with "/FORCE:UNRESOLVED" is ignored if the entry point symbol is unresolved.

Montura avatar Jan 16 '24 13:01 Montura