Skip to content
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions docker/Dockerfile.linux-x86_64-musl
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ RUN apk add --no-cache \
# Install SBT
RUN curl -L "https://github.com/sbt/sbt/releases/download/v1.9.7/sbt-1.9.7.tgz" | tar xz -C /usr/local
ENV PATH="/usr/local/sbt/bin:${PATH}"
ENV IS_MUSL=true

# Install python/pip
ENV PYTHONUNBUFFERED=1
Expand Down
4 changes: 2 additions & 2 deletions src/main/java/org/xerial/snappy/OSInfo.java
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@
package org.xerial.snappy;

import java.io.ByteArrayOutputStream;
import java.io.File;
import java.io.IOException;
import java.io.InputStream;
import java.util.HashMap;
Expand Down Expand Up @@ -237,8 +236,9 @@ public static String getArchName() {

private static boolean isX64Musl() {
try {
return new File("/lib/ld-musl-x86_64.so.1").exists();
return "true".equalsIgnoreCase(System.getenv("IS_MUSL"));
} catch (SecurityException e) {
System.err.println("WARNING! Access to environment variables is restricted, not able to read IS_MUSL property.");
return false;
}
Comment on lines 238 to 243
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

critical

The method isX64Musl now only checks for the IS_MUSL environment variable, but it no longer verifies that the architecture is x86_64. This is a regression from the previous file-based check which was specific to x86_64. If IS_MUSL is set to true on a different architecture (e.g., aarch64), getArchName() will incorrectly return "x86_64-musl", leading to an UnsatisfiedLinkError at runtime.

To fix this, the method should also check the system architecture to ensure it's x86_64 when IS_MUSL is true.

        try {
            if ("true".equalsIgnoreCase(System.getenv("IS_MUSL"))) {
                String osArch = System.getProperty("os.arch");
                String lcArch = osArch.toLowerCase(Locale.US);
                return X86_64.equals(archMapping.get(lcArch));
            }
            return false;
        } catch (SecurityException e) {
            System.err.println("WARNING! Access to environment variables or system properties is restricted, not able to detect musl-x86_64.");
            return false;
        }

}
Expand Down
Loading