ontio/ontology

v1.9.0-beta failing to run on alpine linux

Closed this issue ยท 5 comments

What version of ontology are you using (ontology --version)?

v1.9.0-beta, the latest release from https://github.com/ontio/ontology/releases

Does this issue reproduce with the latest release?

This issue is with the latest release

What operating system are you using (such as macOS, Linux and Windows)?

Alpine Linux, latest release.

What did you do?

Tried to run the v1.9.0-beta ontology binary from within an alpine linux image.

/bin # ls -l | grep ontology
-rwxr-xr-x    1 root     root      33629216 Mar  5 18:16 ontology
/bin # ontology
sh: ontology: not found

What did you expect to see?

A similar output to running the v1.8.2 ontology binary from alpine linux:

/bin # ls -l | grep ontology
-rwxr-xr-x    1 root     root      22088462 Feb 13 16:03 ontology
/bin # ontology
2020/03/05 18:41:28.467604 [INFO ] GID 1, ontology version v1.8.2-0-gda60191a
2020/03/05 18:41:28.468289 [INFO ] GID 1, Config init success
2020/03/05 18:41:28.503304 [INFO ] GID 1, deploy contract address:0239dcf9b4a46f15c5f23f20d52fac916a0bac0d
2020/03/05 18:41:28.503404 [INFO ] GID 1, deploy contract address:08b6dcfed2aace9190a44ae34a320e42c04b46ac
...

What did you see instead?

Seems linux wasn't able to recognize the v1.9.0-beta binary as executable, simply returning sh: ontology: not found as opposed to the normal output logs.

Additional context

  • Comparing the previous v1.8.2 ontology binary to v1.9.0-beta:
/ # file ontology_v1.8.2
ontology_v1.8.2: ELF 64-bit LSB executable, x86-64, version 1 (SYSV), statically linked, Go BuildID=H3MEzRe8AGJsJDmPpG7W/_X27xB1TeFBjESIKKCl3/GHMerwP1qMqTtcTO6PhG/kXHziiIREZqPwrEaobic, not stripped

/ # file ontology_v1.9.0-beta
ontology_v1.9.0-beta: ELF 64-bit LSB executable, x86-64, version 1 (SYSV), dynamically linked, interpreter /lib64/ld-linux-x86-64.so.2, for GNU/Linux 3.2.0, Go BuildID=s59NOi7r3HhTp9FNPi3e/CxYSkAGcBU5tltDTCCl7/J6tHOZls1TLTjQAzLGUY/-ijeolSgA6l4E97GWUXP, BuildID[sha1]=917311dce127d5a0e18002171435471d61c92b74, not stripped

We see that the linux headers are a bit different between both versions - possible this is related to the v1.9.0-beta not being recognized as an executable.

  • Using ldd we see the following:
# ldd ontology_v1.9.0-beta
	/lib64/ld-linux-x86-64.so.2 (0x7fa97309b000)
	libdl.so.2 => /lib64/ld-linux-x86-64.so.2 (0x7fa97309b000)
	libc.so.6 => /lib64/ld-linux-x86-64.so.2 (0x7fa97309b000)
Error loading shared library ld-linux-x86-64.so.2: No such file or directory (needed by ontology)
	libm.so.6 => /lib64/ld-linux-x86-64.so.2 (0x7fa97309b000)
	libpthread.so.0 => /lib64/ld-linux-x86-64.so.2 (0x7fa97309b000)
Error loading shared library libgcc_s.so.1: No such file or directory (needed by ontology)
Error relocating ontology: __longjmp_chk: symbol not found
Error relocating ontology: __snprintf_chk: symbol not found
Error relocating ontology: _Unwind_Resume: symbol not found
Error relocating ontology: _Unwind_Backtrace: symbol not found
Error relocating ontology: _Unwind_GetIPInfo: symbol not found
Error relocating ontology: _Unwind_RaiseException: symbol not found
Error relocating ontology: _Unwind_SetGR: symbol not found
Error relocating ontology: _Unwind_GetDataRelBase: symbol not found
Error relocating ontology: _Unwind_FindEnclosingFunction: symbol not found
Error relocating ontology: _Unwind_GetIP: symbol not found
Error relocating ontology: _Unwind_GetLanguageSpecificData: symbol not found
Error relocating ontology: _Unwind_GetTextRelBase: symbol not found
Error relocating ontology: _Unwind_DeleteException: symbol not found
Error relocating ontology: _Unwind_GetRegionStart: symbol not found
Error relocating ontology: __res_init: symbol not found
Error relocating ontology: _Unwind_SetIP: symbol not found

# ldd ontology_v1.8.2
/lib/ld-musl-x86_64.so.1: ontology: Not a valid dynamic program

Suggesting that the biggest difference between these versions may have to do with static vs. dynamic linkings.

  • Verified that both binaries built correctly, and found the following sizes for each:
    v1.8.2: 22088462
    v1.9.0-beta: 33629216
laizy commented

@BisonAl In v1.9.0-beta we add one c lib dependency which using glibc and enabled CGO. After some searching, Alpine Linux is a lightweight Linux distribution and uses musl libc to reduce the system's size. so I think the easiest way to fix this is using other linux image like debian, ubuntu. sorry for the inconvenience.

Thanks for the insight @laizy, appreciate your quick response!

We prefer using a lightweight image like alpine for security and reliability purposes; I'll see if there's c dependencies we can install to accomodate glibc requirements. If I find a solution to this I'll post it here - perhaps other node operators will run into this as well as they move onto the final 1.9.0 release.

Out of curiosity, do you know the PR/section where this dependency was introduced in https://github.com/ontio/ontology/releases/tag/v1.9.0-beta? Would be helpful to know which specific libraries we need to accomodate.

laizy commented

PR #1133 contains one static lib libwasmjit_onto_interface.a, compiled using https://github.com/ontio/ontio-wasmjit.

Spoke with my team about this, we're going to follow your advice and use a ubuntu or debian base image ๐Ÿ‘

Tried going down the glibc in alpine route, and couldn't find a working solution. The alpine community seems to have been searching for a way around this for a few years now, but no reliable paths forward have stood out so far.

Could be worth making a note in the final 1.9.0 release that alpine will no longer be supported - beyond this I think we are okay to close this issue.

Good to meet you as well @laizy, have been following your releases and PRs for a few months now so glad to get in touch :)

laizy commented

@BisonAl Good to meet you too. And I have updated the release page.