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

EAccessViolation in alpine:3.20 #115

Open
hertznsk opened this issue Nov 17, 2024 · 2 comments
Open

EAccessViolation in alpine:3.20 #115

hertznsk opened this issue Nov 17, 2024 · 2 comments

Comments

@hertznsk
Copy link

Thanks for the great tool!

I'm trying to package it in docker using alpine for use in my CI pipeline, but xidel doesn't work quite right.

Maybe I didn't add some important dependency?

# syntax=docker/dockerfile:1

ARG IMAGE=alpine
ARG VERSION=3.20.3

FROM ${IMAGE}:${VERSION}

LABEL org.opencontainers.image.title="xidel"
ARG IMAGE
ARG VERSION
LABEL org.opencontainers.image.base.name="${IMAGE}:${VERSION}"

# Install Xidel
# renovate: datasource=github-releases depName=benibela/xidel
ARG XIDEL_VERSION="0.9.8"
SHELL ["/bin/ash", "-eo", "pipefail", "-c"]
RUN wget -qO- "https://github.com/benibela/xidel/releases/download/Xidel_${XIDEL_VERSION}/xidel-${XIDEL_VERSION}.linux64.tar.gz" | tar -xzv xidel -C /bin

# Install dependencies
# renovate: datasource=repology depName=alpine_3_20/gcompat versioning=loose
ARG GCOMPAT_VERSION="1.1.0-r4"
# renovate: datasource=repology depName=alpine_3_20/openssl-dev versioning=loose
ARG OPENSSL_VERSION="3.3.2-r1"
RUN apk add --no-cache \
        gcompat=${GCOMPAT_VERSION} \
        openssl-dev=${OPENSSL_VERSION} && \
    # For security reasons, other OS packages should be updated, even at the expense of reproducibility of assemblies
    apk upgrade --no-cache

ENTRYPOINT ["xidel"]
docker run -it --rm my-xidel-image --data 'https://google.com' --xpath3 '.'
... a good result followed by this :
An unhandled exception occurred at $00007F2A754BBD4C:
EAccessViolation: 
  $00007F2A754BBD4C
(gdb) backtrace
#0  0x00007f1777c2fd4c in free_group (g=<optimized out>) at src/malloc/mallocng/free.c:27
#1  nontrivial_free (g=g@entry=0x5555883d25e0, i=i@entry=1) at src/malloc/mallocng/free.c:88
#2  0x00007f1777c2fed8 in __libc_free (p=<optimized out>) at src/malloc/mallocng/free.c:144
#3  0x00007f17778fe023 in ?? ()
#4  0x0000000000000001 in ?? ()
#5  0x00007f17774e9670 in ?? ()
#6  0x00007f17774ea270 in ?? ()
#7  0x00007f177775d360 in ?? ()
#8  0x00000000779227b3 in ?? ()
#9  0xe12fd480382000c0 in ?? ()
#10 0x00007f1777a4fa20 in ?? ()
#11 0x00007f17779227b3 in ?? ()
#12 0x0000000000000000 in ?? ()

I was trying to find the answer in the file https://git.musl-libc.org/cgit/musl/tree/src/malloc/mallocng/free.c. But that didn't tell me anything.

Any ideas?

@benibela
Copy link
Owner

Probably because it is compiled on a glibc system, not musl.

But Xidel does not even use that function. It hardly uses libc. It only links libc to load other libraries that use libc like openSsl.

Have you tried it with a http url, so it does not need to load openssl?

Or you could try to compile it yourself on alpine

@hertznsk
Copy link
Author

hertznsk commented Nov 20, 2024

You're right. There are no problems with HTTP.

I additionally installed the openssl-dbg package and got a more detailed trace:

(gdb) backtrace
#0  0x00007fcd921eed4c in free_group (g=<optimized out>) at src/malloc/mallocng/free.c:27
#1  nontrivial_free (g=g@entry=0x71d54a0, i=i@entry=1) at src/malloc/mallocng/free.c:88
#2  0x00007fcd921eeed8 in __libc_free (p=<optimized out>) at src/malloc/mallocng/free.c:144
#3  0x00007fcd91cfe05b in drbg_ctr_free (vdrbg=0x7fcd91f0e1f0) at providers/implementations/rands/drbg_ctr.c:652
#4  0x00007fcd91b5d360 in EVP_RAND_CTX_free (ctx=<optimized out>) at crypto/evp/evp_rand.c:397
#5  0x00007fcd91b7b4f1 in init_thread_stop (hands=0x7fcd91f63a10, arg=0x0) at crypto/initthread.c:349
#6  init_thread_stop (arg=0x0, hands=0x7fcd91f63a10) at crypto/initthread.c:322
#7  0x00007fcd91b7b650 in OPENSSL_thread_stop () at crypto/initthread.c:234
#8  0x00007fcd91b7acf7 in OPENSSL_cleanup () at crypto/init.c:375
#9  OPENSSL_cleanup () at crypto/init.c:353
#10 0x00007fcd921e6da7 in __funcs_on_exit () at src/exit/atexit.c:34
#11 0x00007fcd921de08f in exit (code=0) at src/exit/exit.c:29
#12 0x00007fcd921e6711 in libc_start_main_stage2 (main=0x400589, argc=10322224, argv=0x7fff9b10c898) at src/env/__libc_start_main.c:95
#13 0x00007fff9b10c8c8 in ?? ()
#14 0x00000000004225dc in ?? ()
#15 0x0000000000000005 in ?? ()
#16 0x000000000040060a in ?? ()
#17 0x00007fcd921e670a in libc_start_main_stage2 (main=0x0, argc=10322224, argv=0x416e8f) at src/env/__libc_start_main.c:95
#18 0x00007fff9b10cfe9 in ?? ()
#19 0x0000000000400588 in ?? ()
#20 0x00007fff9b10c888 in ?? ()
#21 0x00007fff9b10c8c8 in ?? ()
#22 0x0000000000000005 in ?? ()
#23 0x00007fff9b10cf24 in ?? ()
#24 0x00007fff9b10cf33 in ?? ()
#25 0x00007fff9b10cf3a in ?? ()
#26 0x00007fff9b10cf4d in ?? ()
#27 0x00007fff9b10cf56 in ?? ()
#28 0x0000000000000000 in ?? ()

It looks like this is the "most recent" openssl-dev where it works without problems:

apk add --repository=https://dl-cdn.alpinelinux.org/alpine/v3.8/main openssl-dev~1.0

I have not been able to find any issues in openssl on this topic. Although there is a lot of discussion around atexit, it is difficult to judge how applicable this is to this situation.

I will continue to study this situation. I would like to avoid self-compilation - it will be more difficult for me to maintain it.

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

No branches or pull requests

2 participants