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

UnsatisfiedLinkError on Windows with bundled cedar_java_ffi.dll #304

Open
3 tasks done
drnta opened this issue Mar 6, 2025 · 1 comment
Open
3 tasks done

UnsatisfiedLinkError on Windows with bundled cedar_java_ffi.dll #304

drnta opened this issue Mar 6, 2025 · 1 comment
Labels
bug Something isn't working pending-triage Hasn't been triaged yet

Comments

@drnta
Copy link

drnta commented Mar 6, 2025

Before opening, please confirm:

Bug Category

Other

Describe the bug

The attempt to execute simple Java application with cedar-java-uber dependency

<dependency>
    <groupId>com.cedarpolicy</groupId>
    <artifactId>cedar-java</artifactId>
    <classifier>uber</classifier>
    <version>4.3.0</version>
</dependency>

on Windows 10 environment fails with UnsatisfiedLinkError. Looks like the dll does not export the Java functions.

Probably the cause can be in zigbuild usage.
For the bundled dll the dumpbin shows

dumpbin /EXPORTS dlls/original/cedar_java_ffi.dll
Microsoft (R) COFF/PE Dumper Version 14.42.34436.0
Copyright (C) Microsoft Corporation.  All rights reserved.


Dump of file dlls\original\cedar_java_ffi.dll

File Type: DLL

  Section contains the following exports for cedar_java_ffi.dll

    00000000 characteristics
           0 time date stamp
        0.00 version
           1 ordinal base
          33 number of functions
          33 number of names

    ordinal hint RVA      name

          1    0 002A58D0 _GCC_specific_handler
          2    1 008E67C0 _Unwind_Backtrace
          3    2 008FB940 _Unwind_DeleteException
          4    3 008E6750 _Unwind_FindEnclosingFunction
          5    4 008E6830 _Unwind_Find_FDE
          6    5 002A6050 _Unwind_ForcedUnwind
          7    6 008E68C0 _Unwind_GetCFA
          8    7 008E66B0 _Unwind_GetDataRelBase
          9    8 008FB960 _Unwind_GetGR
         10    9 008FB990 _Unwind_GetIP
         11    A 008E68F0 _Unwind_GetIPInfo
         12    B 002A60B0 _Unwind_GetLanguageSpecificData
         13    C 002A60C0 _Unwind_GetRegionStart
         14    D 008E6700 _Unwind_GetTextRelBase
         15    E 002A5D80 _Unwind_RaiseException
         16    F 002A5DC0 _Unwind_Resume
         17   10 008E6640 _Unwind_Resume_or_Rethrow
         18   11 008FB980 _Unwind_SetGR
         19   12 008FB9C0 _Unwind_SetIP
         20   13 00904760 unw_get_fpreg
         21   14 00904830 unw_get_proc_info
         22   15 00904880 unw_get_proc_name
         23   16 00904690 unw_get_reg
         24   17 00904AD4 unw_getcontext
         25   18 00904660 unw_init_local
         26   19 009048B0 unw_is_fpreg
         27   1A 009048E0 unw_is_signal_frame
         28   1B 00DB76C0 unw_local_addr_space
         29   1C 009048D0 unw_regname
         30   1D 00904860 unw_resume
         31   1E 009047A0 unw_set_fpreg
         32   1F 009046D0 unw_set_reg
         33   20 009047F0 unw_step

  Summary

        D000 .data
        1000 .eh_fram
       47000 .pdata
      2A0000 .rdata
       12000 .reloc
      B0D000 .text
        1000 .tls

The same Java code works successfully with cedar_java_ffi.dll built locally using

cargo build --features partial-eval --release --target x86_64-pc-windows-gnu

and forced using CEDAR_JAVA_FFI_LIB env variable.

The dumpbin for this dll shows the exported Java functions

dumpbin /EXPORTS dlls/cargo_build/cedar_java_ffi.dll
Microsoft (R) COFF/PE Dumper Version 14.42.34436.0
Copyright (C) Microsoft Corporation.  All rights reserved.


Dump of file dlls\cargo_build\cedar_java_ffi.dll

File Type: DLL

  Section contains the following exports for cedar_java_ffi.dll

    00000000 characteristics
    67C9C304 time date stamp Thu Mar  6 18:45:08 2025
        0.00 version
           1 ordinal base
          14 number of functions
          14 number of names

    ordinal hint RVA      name

          1    0 00019870 Java_com_cedarpolicy_BasicAuthorizationEngine_callCedarJNI
          2    1 0001A030 Java_com_cedarpolicy_BasicAuthorizationEngine_getCedarJNIVersion
          3    2 0001E880 Java_com_cedarpolicy_formatter_PolicyFormatter_policiesStrToPretty
          4    3 0001B2D0 Java_com_cedarpolicy_model_policy_PolicySet_parsePoliciesJni
          5    4 0001AC80 Java_com_cedarpolicy_model_policy_Policy_parsePolicyJni
          6    5 0001C370 Java_com_cedarpolicy_model_policy_Policy_parsePolicyTemplateJni
          7    6 0001CA10 Java_com_cedarpolicy_model_policy_Policy_toJsonJni
          8    7 0001A720 Java_com_cedarpolicy_model_schema_Schema_parseCedarSchemaJni
          9    8 0001A190 Java_com_cedarpolicy_model_schema_Schema_parseJsonSchemaJni
         10    9 0001D430 Java_com_cedarpolicy_value_EntityIdentifier_getEntityIdentifierRepr
         11    A 0001DB00 Java_com_cedarpolicy_value_EntityTypeName_getEntityTypeNameRepr
         12    B 0001D7C0 Java_com_cedarpolicy_value_EntityTypeName_parseEntityTypeName
         13    C 0001E1B0 Java_com_cedarpolicy_value_EntityUID_getEUIDRepr
         14    D 0001DE50 Java_com_cedarpolicy_value_EntityUID_parseEntityUID

  Summary

        1000 .CRT
        3000 .bss
        1000 .data
        1000 .edata
        1000 .eh_fram
        2000 .idata
       43000 .pdata
      189000 .rdata
       10000 .reloc
      9E7000 .text
        1000 .tls
       FF000 .xdata

Expected behavior

The code works with bundled windows dll

Reproduction steps

See description

Code Snippet

package org.example;

import com.cedarpolicy.model.exception.InternalException;
import com.cedarpolicy.model.policy.PolicySet;

public class Main {
    public static void main(String[] args) throws InternalException {
        PolicySet.parsePolicies("");
    }
}

Log output

Exception in thread "main" java.lang.UnsatisfiedLinkError: 'com.cedarpolicy.model.policy.PolicySet com.cedarpolicy.model.policy.PolicySet.parsePoliciesJni(java.lang.String)'
	at com.cedarpolicy.model.policy.PolicySet.parsePoliciesJni(Native Method)
	at com.cedarpolicy.model.policy.PolicySet.parsePolicies(PolicySet.java:128)
	at org.example.Main.main(Main.java:8)

Additional configuration

No response

Operating System

Windows 10

Additional information and screenshots

No response

@drnta drnta added bug Something isn't working pending-triage Hasn't been triaged yet labels Mar 6, 2025
@drnta drnta changed the title UnsatisfiedLinkError on Windows with bundled native cedar_java_ffi.dll UnsatisfiedLinkError on Windows with bundled cedar_java_ffi.dll Mar 6, 2025
@01epa
Copy link

01epa commented Mar 7, 2025

Got the same issue om my local windows machine

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working pending-triage Hasn't been triaged yet
Projects
None yet
Development

No branches or pull requests

2 participants