Skip to content
This repository has been archived by the owner on Jun 4, 2024. It is now read-only.

Segfaults on node 17 #104

Open
Ten0 opened this issue Dec 21, 2021 · 6 comments
Open

Segfaults on node 17 #104

Ten0 opened this issue Dec 21, 2021 · 6 comments

Comments

@Ten0
Copy link

Ten0 commented Dec 21, 2021

Since we've updated to node 17, using pg-native in combination with pg results in a segfault of the node process.

@dzuelke
Copy link

dzuelke commented Jul 22, 2022

I suspect this is due to OpenSSL 3 in Node.js 17 and newer.

@infinityfye
Copy link

infinityfye commented Dec 4, 2022

Indeed. I've confirmed those segfaults are due to OpenSSL 3.


timestamp message
1670159721000 /lib/x86_64-linux-gnu/libpthread.so.0(+0x13140)[0x7fbec4a93140]
1670159721000 /usr/lib/x86_64-linux-gnu/libssl.so.1.1(SSL_get_peer_certificate+0x13)[0x7fbec0366143]
1670159721000 /usr/lib/x86_64-linux-gnu/libpq.so.5(+0x25f1d)[0x7fbec03e6f1d]
1670159721000 /usr/lib/x86_64-linux-gnu/libpq.so.5(PQconnectPoll+0xd68)[0x7fbec03d1628]
1670159721000 /usr/lib/x86_64-linux-gnu/libpq.so.5(+0x118f7)[0x7fbec03d28f7]
1670159721000 /usr/lib/x86_64-linux-gnu/libpq.so.5(PQconnectdb+0x38)[0x7fbec03d59f8]
1670159721000 /home/node/node_modules/libpq/build/Release/addon.node(+0x8144)[0x7fbec0423144]
1670159721000 /home/node/node_modules/libpq/build/Release/addon.node(+0x9de3)[0x7fbec0424de3]
1670159721001 node[0x1647ba4]
1670159721001 /lib/x86_64-linux-gnu/libpthread.so.0(+0x7ea7)[0x7fbec4a87ea7]
1670159721001 /lib/x86_64-linux-gnu/libc.so.6(clone+0x3f)[0x7fbec49a7a2f]
1670159722357 Segmentation fault (core dumped)

I deploy on AWS ECS and we use the official Node docker images to build and deploy on.
I've encountered those on both 18-bullseye and 18-buster.
So, apart from using Node16 images, are there any advice you could give?

@0xkarl
Copy link

0xkarl commented Dec 11, 2022

Indeed. I've confirmed those segfaults are due to OpenSSL 3.

timestamp message
1670159721000 /lib/x86_64-linux-gnu/libpthread.so.0(+0x13140)[0x7fbec4a93140]
1670159721000 /usr/lib/x86_64-linux-gnu/libssl.so.1.1(SSL_get_peer_certificate+0x13)[0x7fbec0366143]
1670159721000 /usr/lib/x86_64-linux-gnu/libpq.so.5(+0x25f1d)[0x7fbec03e6f1d]
1670159721000 /usr/lib/x86_64-linux-gnu/libpq.so.5(PQconnectPoll+0xd68)[0x7fbec03d1628]
1670159721000 /usr/lib/x86_64-linux-gnu/libpq.so.5(+0x118f7)[0x7fbec03d28f7]
1670159721000 /usr/lib/x86_64-linux-gnu/libpq.so.5(PQconnectdb+0x38)[0x7fbec03d59f8]
1670159721000 /home/node/node_modules/libpq/build/Release/addon.node(+0x8144)[0x7fbec0423144]
1670159721000 /home/node/node_modules/libpq/build/Release/addon.node(+0x9de3)[0x7fbec0424de3]
1670159721001 node[0x1647ba4]
1670159721001 /lib/x86_64-linux-gnu/libpthread.so.0(+0x7ea7)[0x7fbec4a87ea7]
1670159721001 /lib/x86_64-linux-gnu/libc.so.6(clone+0x3f)[0x7fbec49a7a2f]
1670159722357 Segmentation fault (core dumped)
I deploy on AWS ECS and we use the official Node docker images to build and deploy on. I've encountered those on both 18-bullseye and 18-buster. So, apart from using Node16 images, are there any advice you could give?

same. trying to use this on aws lambda w/ a custom image and getting that error:

FROM public.ecr.aws/lambda/nodejs:16

RUN yum update -y && yum install -y postgresql-devel python3 @development
COPY package.json ${LAMBDA_TASK_ROOT}
RUN npm install
...

@0xkarl
Copy link

0xkarl commented Dec 11, 2022

got it working with libpq:

FROM public.ecr.aws/lambda/nodejs:16

RUN yum update -y && \
  yum remove postgresql postgresql-devel -y && \
  yum install -y python3 make gcc perl-core pcre-devel wget zlib-devel @development readline-devel && \
  curl -o openssl.tar.gz https://www.openssl.org/source/openssl-1.1.1s.tar.gz && \
  tar -xvf openssl.tar.gz && \
  cd openssl-1.1.1s/ && \
  ./config --prefix=/usr --openssldir=/etc/ssl --libdir=lib no-shared zlib-dynamic && \
  make && \
  make test && \
  make install && \
  cd .. && \
  curl -o postgresql.tar.gz http://ftp.postgresql.org/pub/source/v13.7/postgresql-13.7.tar.gz && \
  tar -xvf postgresql.tar.gz && \
  cd postgresql-13.7/ && \
  ./configure --prefix=/usr && \
  make && \
  make install
COPY package.json ${LAMBDA_TASK_ROOT}
RUN npm install
...

@wzrdtales
Copy link

@brianc is this going to be fixed?

@maclockard
Copy link

I think the underlying issue comes from node-libpq: brianc/node-libpq#94.

FWIW this is still happening on node 18

@charmander charmander changed the title Sefgaults on node 17 Segfaults on node 17 Jan 3, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants