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

nodejs example failed on Alpine3.11 #352

Open
XinnWang opened this issue Aug 28, 2021 · 8 comments
Open

nodejs example failed on Alpine3.11 #352

XinnWang opened this issue Aug 28, 2021 · 8 comments

Comments

@XinnWang
Copy link

Currently, we need to use alpine to do some web application. We tried to build zcm in docker with base image "node:12.22.5-alpine3.11".

What we did to make it work?

apk add  bash git g++ make pkgconfig python tar zeromq-dev
mv zcm/transport/transport_serial.cpp zcm/transport/transport_serial.abb
mv zcm/transport/transport_can.cpp zcm/transport/transport_can.abb
sed -i 's/uint/unsigned int/g' zcm/transport/udpm/udpmsocket.cpp
sed -i 's/uint/unsigned int/g' gen/GetOpt.cpp
sed -i "s@<sys/poll.h>@<poll.h>@g" zcm/transport/udpm/udpm.hpp
./waf configure --use-ipc --use-udpm --use-zmq  --use-nodejs
./waf build
./waf install

What happened?

When we tried to run the node example, we got unexpected segment fault. This does not happen on system like ubuntu. The error log is as below.

bash-5.0# node app.js
listening on *:3000
Segmentation fault

But cpp examples can run successfully.

@jbendes
Copy link
Member

jbendes commented Aug 28, 2021 via email

@didibaba
Copy link

The dockerfile is as below.

FROM node:12.22.5-alpine3.11

RUN apk update && apk upgrade && \
    apk add --no-cache bash git g++ make pkgconfig python tar zeromq-dev && \
    git config --global url.git://github.com/.insteadOf https://github.com/ && \
    yarn config set registry https://registry.npm.taobao.org/ && \
    wget https://github.com/ZeroCM/zcm/archive/v1.0.3.tar.gz && \
    tar xzf v1.0.3.tar.gz && \
    cd zcm-1.0.3 && \
    ./waf configure --use-ipc --use-udpm --use-zmq  --use-nodejs && \ 
    mv zcm/transport/transport_serial.cpp zcm/transport/transport_serial.abb && \
    mv zcm/transport/transport_can.cpp zcm/transport/transport_can.abb && \ 
    sed -i 's/uint/unsigned int/g' zcm/transport/udpm/udpmsocket.cpp && \
    sed -i 's/uint/unsigned int/g' gen/GetOpt.cpp && \
    sed -i "s@<sys/poll.h>@<poll.h>@g" zcm/transport/udpm/udpm.hpp && \
    ./waf build && \
    ./waf install && \
    cd .. && \
    rm -fr zcm-1.0.3 v1.0.3.tar.gz
ENV ZCM_DEFAULT_URL="udpm://239.255.76.67:7667?ttl=0"

After docker image is successfully built, I just run npm run preintall && npm install && npm run postinstall to make the sample properly work. Then you will see the segment fault I mentioned before.

THX.

@jbendes
Copy link
Member

jbendes commented Aug 28, 2021

You need to build the zcm repo in order to use the examples. I would recommend building from source (very fast) over using a published image. You'll need to configure with --use-all in order to build the examples. We can certainly put in some effort to make it so it only builds the examples that you have enabled with the configure flags, but right now it builds them all

@jbendes
Copy link
Member

jbendes commented Aug 28, 2021

Okay so I pushed up a branch that allows you to build only examples you configure for - inf-minor. However I'm still seeing the segfault. I'm honestly not sure where/why/how that's happening and I'm not really sure how to debug it either. I'll try gdb-ing the node invocation at some point but I wouldn't rely on me for that

@jbendes
Copy link
Member

jbendes commented Aug 28, 2021

Confirmed that the segfault happens on receipt of a message. Can also confirm that gdb thinks it's happening in the dispatchMsg function in blocking.cpp.

@didibaba
Copy link

Thank you for your quick response. Hope this can be solved soon.

@jbendes
Copy link
Member

jbendes commented Aug 31, 2021

Yeah I'm sorry I wasn't able to track it down with a few hours of work. Unfortunately I don't have more time than that right now to dedicate to this. Are you unable to just use an ubuntu image for now? I think the node code really needs to be rewritten at this point. The ffi interface that nodes uses I don't even think is supported anymore

@jbendes
Copy link
Member

jbendes commented Sep 23, 2021

After more research into alpine, while technically you can build zcm on alpine by just making sure to install all the proper dependencies, there is no clang support, no sanitizer support, and no glibc support. So debugging is a huge pain. Unfortunately I am not going to be able to put in the time to support fixing this bug. I have a gut feeling that simply moving to the new nodejs c API would fix this issue. But I have no idea how long it will be until we do that.

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

3 participants