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

Fix UnsatisfiedLinkError in some rare cases #2700

Merged
merged 1 commit into from
Dec 16, 2024

Conversation

res-life
Copy link
Collaborator

closes #2699

why this issue occurs

The original code is:

public class Hash {
  public static final int MAX_STACK_DEPTH = getMaxStackDepth();

  static {
    NativeDepsLoader.loadNativeDeps();
  }

  private static native int getMaxStackDepth();
}

The JVM will first execute:

public static final int MAX_STACK_DEPTH = getMaxStackDepth();

then:

  static {
    NativeDepsLoader.loadNativeDeps();
  }

getMaxStackDepth is a native function which is in the JNI so file.
If do not load native so first, the getMaxStackDepth can not be used and it reports: UnsatisfiedLinkError

why this issue do not occur in most cases

If other classes already loaded the JNI so file, then it does not report this error.
e.g.:

JSONUtils.MAX_PATH_DEPTH
Hash.MAX_STACK_DEPTH

The above call seq will not report error, becasue JSONUtils.MAX_PATH_DEPTH will trigger loading JNI so file.

fix

Load the JNI so file first in Hash

Signed-off-by: Chong Gao [email protected]

@res-life
Copy link
Collaborator Author

build

@res-life res-life requested review from ttnghia and ustcfy December 16, 2024 07:48
@ttnghia ttnghia merged commit 49ea936 into NVIDIA:branch-25.02 Dec 16, 2024
5 checks passed
@res-life res-life deleted the fix-UnsatisfiedLinkError branch December 17, 2024 01:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[BUG] rapids_integration-scala213-dev-github tests failing
3 participants