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

Running lit commands in docker build segfault at exit. #292

Open
creationix opened this issue Jul 1, 2021 · 3 comments
Open

Running lit commands in docker build segfault at exit. #292

creationix opened this issue Jul 1, 2021 · 3 comments
Labels

Comments

@creationix
Copy link
Member

I reproduced this with latest luvi (v2.12.0) on both alpine and ubuntu docker environments with both building from source and using the prebuilt get-lit luvi binaries. I don't think it's a luvi issue entirely.

A simple docker based luvi+lit app looks something like this:

FROM creationix/lit
ADD package.lua .
RUN lit install
ADD main.lua .
EXPOSE 8080
CMD ["luvi", "."]

This normally works great, but with the latest version of lit, it will fail after lit install finishes:

$ docker build webserver/
Sending build context to Docker daemon  4.096kB
Step 1/6 : FROM creationix/lit
 ---> 59a1da203be1
Step 2/6 : ADD package.lua .
 ---> e22d625ce600
Step 3/6 : RUN lit install
 ---> Running in f58a663faf85
lit version: 3.8.5
luvi version: v2.12.0
command: install
create config: /root/.litconfig
connecting: wss://lit.luvit.io/
fetching: 1 object
...
fetching: 1 object
including dependency: coro-channel (3.0.3)
...
including dependency: weblit-server (3.1.3)
installing package: creationix/[email protected]
...
installing package: luvit/[email protected]
done: success

The command '/bin/sh -c lit install' returned a non-zero code: 139

I'm wondering if it's related to some recent changes to how stdout is managed in pretty-print? Not sure really.

I can work around the issue in the Dockerfile by ignoring the return value like RUN lit install || true. As far as I can tell, the result is correct.

I don't think it's related to a lack of tty. I can use docker run creationix/lit lit ... with or without a pseudo terminal and there are no segfaults for any lit command. All lit commands segfault while exiting during the docker build step.

@squeek502 squeek502 added the bug label Jul 1, 2021
@rdw-software
Copy link
Contributor

Not sure if it's any help, but I recently faced a similar issue when testing electron apps. It would segfault only on the Ubuntu VM, apparently because the output could not be rendered. My workaround was something like export DISPLAY=:45 && xvfb-run --server-num 45 before running the command in question, though I'm not a Linux expert so that might be bad.

I used GitHub actions and they run inside a Docker environment, so I figured it might be at least tangentially related... Could also be something else, since I also had the same issue when accessing the VM via ssh.

@jumpyapple
Copy link

jumpyapple commented Aug 6, 2021

Run into the same issue trying to setup lua in a docker container. Here are some artifacts from me digging into the issue.

FROM ubuntu:latest
RUN apt-get update && apt-get upgrade -y
RUN apt-get install -y tzdata && \
    rm /etc/localtime && \
    ln -fs /usr/share/zoneinfo/US/Eastern /etc/localtime && \
    dpkg-reconfigure -f noninteractive tzdata
RUN apt-get install -y lua5.3 liblua5.3-dev sqlite3 libsqlite3-dev vim curl build-essential unzip gdb
RUN cd /root && curl -L https://github.com/luvit/lit/raw/master/get-lit.sh | sh && \
    mv ./lit /usr/local/bin/lit && \
    mv ./luvi /usr/local/bin/luvi && \
    mv ./luvit /usr/local/bin/luvit
RUN gdb -batch -ex "run" -ex "bt" --args lit help 2>&1 || true

Build output:

Step 8/8 : RUN gdb -batch -ex "run" -ex "bt" --args lit help 2>&1 || true
 ---> Running in f7c497d4134e
warning: Error disabling address space randomization: Operation not permitted
[Thread debugging using libthread_db enabled]
Using host libthread_db library "/lib/x86_64-linux-gnu/libthread_db.so.1".
lit version: 3.8.5
luvi version: v2.11.0-21-g5d1052f
command: help

... help message

done: success


Program received signal SIGABRT, Aborted.
__GI_raise (sig=sig@entry=6) at ../sysdeps/unix/sysv/linux/raise.c:50
50      ../sysdeps/unix/sysv/linux/raise.c: No such file or directory.
#0  __GI_raise (sig=sig@entry=6) at ../sysdeps/unix/sysv/linux/raise.c:50
#1  0x00007fec82031859 in __GI_abort () at abort.c:79
#2  0x000000000045d1bd in uv.io_poll.cold ()
#3  0x000000000052c83a in uv_run ()
#4  0x0000000000494f7e in luv_run ()
#5  0x000000000052462a in lj_BC_FUNCC ()
#6  0x000000000052561a in lj_ff_coroutine_wrap_aux ()
#7  0x000000000051023f in lua_pcall ()
#8  0x000000000045d36b in main ()
Removing intermediate container f7c497d4134e
 ---> f967125d3a6f

@jumpyapple
Copy link

Some more output when CMAKE_BUILD_TYPE=Debug for luvi.

FROM ubuntu:latest
RUN apt-get update && apt-get upgrade -y
RUN apt-get install -y tzdata && \
    rm /etc/localtime && \
    ln -fs /usr/share/zoneinfo/US/Eastern /etc/localtime && \
    dpkg-reconfigure -f noninteractive tzdata
RUN apt-get install -y lua5.3 liblua5.3-dev sqlite3 libsqlite3-dev vim curl build-essential unzip gdb cmake
RUN apt-get install -y git zlib1g-dev libbz2-dev libeditline-dev

# Manual build of luvi
RUN cd /root && git clone --recursive --branch v2.12.0 https://github.com/luvit/luvi.git && \
    cd luvi && \
    sed -i 's/DCMAKE_BUILD_TYPE=Release/DCMAKE_BUILD_TYPE=Debug/' Makefile && \
    make regular && \
    make && \
    make test
RUN cd /root/ && \
    curl -L -f -o lit.zip "https://lit.luvit.io/packages/luvit/lit/v3.8.5.zip" && \
    ./luvi/build/luvi lit.zip -- make lit.zip || true
RUN cd /root && \
    gdb -batch -ex "set follow-fork-mode child" -ex "run" -ex "bt" -ex "frame 2" -ex "list"  --args /root/lit help 2>&1 || true
Program received signal SIGABRT, Aborted.
__GI_raise (sig=sig@entry=6) at ../sysdeps/unix/sysv/linux/raise.c:50
50      ../sysdeps/unix/sysv/linux/raise.c: No such file or directory.
#0  __GI_raise (sig=sig@entry=6) at ../sysdeps/unix/sysv/linux/raise.c:50
#1  0x00007ff87df84859 in __GI_abort () at abort.c:79
#2  0x0000561b59bd84a2 in uv__io_poll (loop=0x7ff87df4ed98, timeout=0) at /root/luvi/deps/luv/deps/libuv/src/unix/linux-core.c:254
#3  0x0000561b59bbf63c in uv_run (loop=0x7ff87df4ed98, mode=UV_RUN_DEFAULT) at /root/luvi/deps/luv/deps/libuv/src/unix/core.c:385
#4  0x0000561b59af0242 in luv_run (L=0x7ff87df571f0) at /root/luvi/deps/luv/src/loop.c:36
#5  0x0000561b59bb4f9a in lj_BC_FUNCC () at buildvm_x86.dasc:851
#6  0x0000561b59bb5f8a in lj_ff_coroutine_wrap_aux () at buildvm_x86.dasc:1808
#7  0x0000561b59b27648 in lua_pcall (L=0x7ff87df3d380, nargs=1, nresults=1, errfunc=2) at /root/luvi/deps/luv/deps/luajit/src/lj_api.c:1169
#8  0x0000561b59ae2a90 in main (argc=2, argv=0x561b5b5ff2a0) at /root/luvi/src/main.c:191
#2  0x0000561b59bd84a2 in uv__io_poll (loop=0x7ff87df4ed98, timeout=0) at /root/luvi/deps/luv/deps/libuv/src/unix/linux-core.c:254
254             abort();
249         /* XXX Future optimization: do EPOLL_CTL_MOD lazily if we stop watching
250          * events, skip the syscall and squelch the events after epoll_wait().
251          */
252         if (epoll_ctl(loop->backend_fd, op, w->fd, &e)) {
253           if (errno != EEXIST)
254             abort();
255
256           assert(op == EPOLL_CTL_ADD);
257
258           /* We've reactivated a file descriptor that's been watched before. */

The actual location in libuv repository get moved by this commit libuv/libuv@caf22dd

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

4 participants