You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Kafkactl will produce a segmentation fault when running the native-image in a Alpine Docker image
/# kafkactl
Error relocating /usr/local/bin/kafkactl: __strdup: symbol not found
Error relocating /usr/local/bin/kafkactl: __strtok_r: symbol not found
Error relocating /usr/local/bin/kafkactl: __isnan: symbol not found
Error relocating /usr/local/bin/kafkactl: __isnanf: symbol not found
Segmentation fault
To Reproduce
Create a Alpine docker image, download kafkactl from the release and add it to the PATH
Execute kafkactl
Expected behavior
Should work as expected without the segmentation fault
Environment (please complete the following information):
Kafkactl distribution and version [Native Image, v1.14.0]
Steps taken to try and solve the problem
The issue is mainly due to Alpine not using glibc but musl, and so some symbols are missings when running the native-image.
The easiest way to fix this issue is to use GraalVM Static Native Executable see here
As explained in the documentation :
A static native executable is a statically linked binary that can be used without any additional library dependencies. A static native executable is easy to distribute and deploy on a slim or distroless container (a scratch container). You can create a static native executable by statically linking it against musl-libc, a lightweight, fast and simple libc implementation.
In order to apply this to kafkactl some tinkering is required :
Edit the build.gradle to add the --static --libc=musl :
The CI/CD needs some changes as well, as it requires the musl libc compiler in order to link it into the native image.
We can refer to this
How ever small caveat the documentation provides the url for the latest version of musl however it's not compatible with the native image as mentioned in the issue #4076 from oracle/graal
Hey everyone :)
As @ dainiusjocas mentioned, this problem started happening due to a change in the gcc musl toolchain build process that started treating relocations in a read-only section at runtime as an error rather than a compile time warning.
I don't think we can report this issue to the musl toolchain developers - this was probably an intended change from their side.
The reason why it fails with native-image is because a read only section that gets placed in a read only segment at runtime, .svm_heap, has relocations that can only be resolved at program startup.
I don't see a trivial way to get rid of these relocations (I assume most of them come from method address relocations, for e.g. for the vtables).
As a workaround, it's probably best to use GCC 10.2.1 for cross-compiling to musl. Alternatively, there may be a ld option that can prevent the linker from failing due to these relocations, but I'm not sure which one it is exactly :/
Describe the bug
Kafkactl will produce a segmentation fault when running the native-image in a Alpine Docker image
/# kafkactl Error relocating /usr/local/bin/kafkactl: __strdup: symbol not found Error relocating /usr/local/bin/kafkactl: __strtok_r: symbol not found Error relocating /usr/local/bin/kafkactl: __isnan: symbol not found Error relocating /usr/local/bin/kafkactl: __isnanf: symbol not found Segmentation fault
To Reproduce
Expected behavior
Should work as expected without the segmentation fault
Environment (please complete the following information):
Steps taken to try and solve the problem
The issue is mainly due to Alpine not using glibc but musl, and so some symbols are missings when running the native-image.
The easiest way to fix this issue is to use GraalVM Static Native Executable see here
As explained in the documentation :
In order to apply this to kafkactl some tinkering is required :
Edit the
build.gradle
to add the--static --libc=musl
:The CI/CD needs some changes as well, as it requires the musl libc compiler in order to link it into the native image.
We can refer to this
How ever small caveat the documentation provides the url for the latest version of musl however it's not compatible with the native image as mentioned in the issue #4076 from oracle/graal
Originally posted by @gradinac in oracle/graal#4076 (comment)
The latest functional version is
https://more.musl.cc/10.2.1/x86_64-linux-musl/x86_64-linux-musl-native.tgz
The text was updated successfully, but these errors were encountered: