oracle / graal

GraalVM compiles Java applications into native executables that start instantly, scale fast, and use fewer compute resources 🚀
https://www.graalvm.org
Other
20.29k stars 1.63k forks source link

Exception when using @CFunction on Windows #4760

Closed Montura closed 8 months ago

Montura commented 2 years ago

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:

More details

Expected output (digits are not valuable):
OS name: mac os
JNI time = 20
C time = 6
dummy time = 6
native time = 1
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

oubidar-Abderrahim commented 2 years ago

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

Montura commented 2 years ago

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

oubidar-Abderrahim commented 1 year ago

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 commented 8 months ago

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

Montura commented 8 months ago

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.