GeezerVisonThe World Wide Web, restored to 800 pixels of glory. | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| Home|About|Gaming cabinet|Archives|How it works|Starter sites | ||||||||||||||||||||||||||||||||||||||||||||||||||||
GeezerVison is showing github.com — When shaded, `OpenSsl.isAvailable()` hangs on Alpine x86_64 · Issue #1024 · netty/netty-tcnative Closed Milestone DescriptionSummary, written by a humanIf the tc-native library is shaded/relocated, The infinite loop is a regression in version 2.0.82; in earlier versions, We ran into this at Couchbase, where we shade Netty and tc-native into the Couchbase JVM SDKs. Root cause: the x86_64 musl fallbacks This only happens when the library is shaded, because netty-tcnative/openssl-dynamic/src/main/c/sslcontext.c Lines 3259 to 3261 in 68007b7
We suspect this only happens with the x86_64 artifact because it was built using an old Centos 6 toolchain; the working arm64 artifact appears to be using a Centos 7 toolchain. The proposed fix (see below in the collapsed section) resolves the issue on Centos 6. An alternate solution might be to update the x86 builder to Centos 7, although we haven't explored that path. Netty versionnetty-tcnative-boringssl-static 2.0.82.Final through 2.0.84.Final, linux-x86_64. JVM versionNot JVM-specific. Seen with Eclipse Temurin 21 on Alpine. OS versionAlpine Linux 3.22 / 3.24 (musl 1.2.5), x86_64 AI analysis and proposed fixThe rest of this issue report, including the proposed fix, was generated by AI tools. Click to expand the AI analysisExpected behaviorOn musl (Alpine Linux) x86_64, the weak fallbacks in Actual behaviorIn the linux-x86_64 artifacts, The linux-aarch_64 artifact is correct: there, On glibc these fallbacks are never used, because glibc's own definitions win. On musl, libc doesn't define these names, so the library's PLT entries bind to the looping fallbacks. Where it's hit. So loading a relocated/shaded copy of the library on Alpine x86_64 hangs forever inside
CauseThe x86_64 artifacts are built against glibc 2.12 headers (
TCN_MUSL_COMPAT char *__strdup(const char *str) { return strdup(str); /* expands to: return __strdup (str); */ } Each fallback calls itself, and GCC turns the unconditional self tail call into Steps to reproduceThis needs no JVM. It uses the upstream
#include <dlfcn.h> #include <stdio.h> int main(int argc, char **argv) { void *lib = dlopen(argv[1], RTLD_LAZY); if (!lib) { printf("dlopen failed: %s\n", dlerror()); return 1; } char *(*fn)(const char *) = (char *(*)(const char *)) dlsym(lib, "__strdup"); printf("libc defines __strdup: %s\n", dlsym(RTLD_DEFAULT, "__strdup") ? "yes" : "no"); printf("calling the library's __strdup at %p...\n", (void *) fn); fflush(stdout); printf("__strdup(\"hello\") = %s\n", fn("hello")); return 0; } unzip -j netty-tcnative-boringssl-static-2.0.84.Final-linux-x86_64.jar META-INF/native/libnetty_tcnative_linux_x86_64.so docker run --rm --platform linux/amd64 -v "$PWD:/w" -w /w alpine:3.22 sh -c \ 'apk add -q gcc musl-dev && gcc -o strdup_loop strdup_loop.c && timeout 20 ./strdup_loop /w/libnetty_tcnative_linux_x86_64.so; echo "exit=$?"' The program asks the library for its Output with 2.0.84.Final (the bug): How to read it:
Output with the fix (the patched Here the fallback is still used, since musl still has no Proposed fixIn /* glibc-internal math aliases emitted via APR's configure-era headers. */
TCN_MUSL_COMPAT int __isinf(double value) {
- return isinf(value);
+ /* Not isinf(): old glibc (e.g. 2.12) defines it as a macro calling __isinf.
+ Not (isinf)(): musl has no isinf function symbol. */
+ return __builtin_isinf_sign(value);
}
TCN_MUSL_COMPAT int __isnan(double value) {
- return isnan(value);
+ return __builtin_isnan(value);
}
/* glibc-internal alias APR links against directly. */
TCN_MUSL_COMPAT char *__strdup(const char *str) {
- return strdup(str);
+ /* Parentheses suppress old glibc's (e.g. 2.12) `#define strdup(s) __strdup (s)`,
+ which would otherwise make this call itself. */
+ return (strdup)(str);
}
Tested. We compiled the original and the patched file the way the release build does:
We then called each fallback through
We didn't rebuild netty-tcnative itself. To check that fixing these fallbacks is enough, we ran the released, relocated 2.0.84 library on Alpine x86_64 with the patched fallbacks Related hardening
Why arm64 isn't affectedShort answer: the aarch64 build uses newer glibc headers. There, What differs
WhyOld glibc headers define macros that turn calls into their
Takeaways
Activity
MetadataMetadataAssigneesLabelsNo labels TypeProjectsMilestoneRelationshipsDevelopmentIssue actions | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| You are visitor 01402775 — GeezerVison does not store the pages you look up. Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required. |