node-rdkafka: node-rdkafka 2.3.0 Segmentation fault
Since 2.3.0, as soon as connect()
method is called (from consumer or producer), a Segmentation fault occured.
Steps to reproduce using docker and e2e tests for brevity :
Dockerfile :
FROM node:9-stretch
RUN npm i node-rdkafka
WORKDIR /node_modules/node-rdkafka
RUN npm i
ENV KAFKA_HOST=localhost:29092
e2e tests run :
$ docker build -t rdkafka .
(...)
$ docker run --net host rdkafka make e2e
Consumer
commit
Makefile:63: recipe for target 'e2e' failed
make: *** [e2e] Segmentation fault (core dumped)
About this issue
- Original URL
- State: closed
- Created 6 years ago
- Reactions: 4
- Comments: 17 (7 by maintainers)
The problem here is that librdkafka built is not used inside node module, because node module links against system librdkafka, not the local librdkafka. And system’s librdkafka is usually linked against OpenSSL 1.1 but node is built against OpenSSL 1.0, and this causes the segmentation fault. See PR #388 for the fix.
Also in Debian, you should make sure that you have
libssl1.0-dev
installed, notlibssl-dev
(1.1) so that npm builds librdkafka correctly against OpenSSL 1.0.On Fedora x86_64, with node 8.9.4 and suitable debug parts enabled (Ugh!):
I’m using a non-SSL connection to a local kafka broker, but from what I understand this is generic SSL-support code initialization?
EDIT: On a whim I modified
node_modules/node-rdkafka/configure
in my project, added--disable-ssl
, and executednpm rebuild
. This fixes the immediate problem, and I can work again.So, poking further through NodeJS: Essentially a third-party module cannot really link to OpenSSL without the danger of that conflicting in some way with whatever NodeJS comes bundled with.
Actually this is “reverse”, instead I needed to get librdkafka/node-rdkafka agree with the version used by NodeJS. On Fedora this required to remove the openssl-devel package, and instead installing the compat-openssl10-devel package:
With this setup my reproducible segfaults go away after running
npm rebuild node-rdkafka
in the affected projects.Maybe this could be added as a requirement or such in the README file here?