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

strcpy_chk: symbol not found #180

Closed
Lilja opened this issue Feb 17, 2024 · 27 comments
Closed

strcpy_chk: symbol not found #180

Lilja opened this issue Feb 17, 2024 · 27 comments

Comments

@Lilja
Copy link

Lilja commented Feb 17, 2024

I'm trying to package my API into a docker image, using node:20-alpine.

Running my app leads to

2024-02-17T11:15:12.739 app[080e513b19e298] ams [info] node:internal/modules/cjs/loader:1473
2024-02-17T11:15:12.739 app[080e513b19e298] ams [info] return process.dlopen(module, path.toNamespacedPath(filename));
2024-02-17T11:15:12.739 app[080e513b19e298] ams [info] ^
2024-02-17T11:15:12.739 app[080e513b19e298] ams [info] Error: Error relocating /app/node_modules/@libsql/linux-x64-musl/index.node: __strcpy_chk: symbol not found
2024-02-17T11:15:12.739 app[080e513b19e298] ams [info] at Module._extensions..node (node:internal/modules/cjs/loader:1473:18)
2024-02-17T11:15:12.739 app[080e513b19e298] ams [info] at Module.load (node:internal/modules/cjs/loader:1207:32)
2024-02-17T11:15:12.739 app[080e513b19e298] ams [info] at Module._load (node:internal/modules/cjs/loader:1023:12)
2024-02-17T11:15:12.739 app[080e513b19e298] ams [info] at Module.require (node:internal/modules/cjs/loader:1235:19)
2024-02-17T11:15:12.739 app[080e513b19e298] ams [info] at require (node:internal/modules/helpers:176:18)
2024-02-17T11:15:12.739 app[080e513b19e298] ams [info] at Object.<anonymous> (/app/node_modules/libsql/index.js:41:24)
2024-02-17T11:15:12.739 app[080e513b19e298] ams [info] at Module._compile (node:internal/modules/cjs/loader:1376:14)
2024-02-17T11:15:12.739 app[080e513b19e298] ams [info] at Module._extensions..js (node:internal/modules/cjs/loader:1435:10)
2024-02-17T11:15:12.739 app[080e513b19e298] ams [info] at Module.load (node:internal/modules/cjs/loader:1207:32)
2024-02-17T11:15:12.739 app[080e513b19e298] ams [info] at Module._load (node:internal/modules/cjs/loader:1023:12) {
2024-02-17T11:15:12.739 app[080e513b19e298] ams [info] code: 'ERR_DLOPEN_FAILED'
2024-02-17T11:15:12.739 app[080e513b19e298] ams [info] } 

It might be an issue with glibc/musl. See this issue

Do the libsql team have an opinion of what type of distribution I should use?

Dockerfile
FROM node:20-alpine as base

WORKDIR /app
COPY ./dist /app/dist

ARG GIT_SHA
ENV GIT_REVISION=$GIT_SHA

RUN npm install @libsql/client

EXPOSE 4000
CMD [ "node", "--no-warnings=ExperimentalWarning", "dist/index.js" ]
@lovell
Copy link

lovell commented Feb 25, 2024

I've just hit this when upgrading from v0.2.0 to v0.3.x.

It looks like the @libsql/linux-x64-musl/index.node binaries since v0.3.1 might have been built/linked against glibc rather than musl.

v0.2.0:

# ldd node_modules/@libsql/linux-x64-musl/index.node
	/lib/ld-musl-x86_64.so.1 (0x7f2fdf705000)
	libgcc_s.so.1 => /usr/lib/libgcc_s.so.1 (0x7f2fdf052000)
	libc.so => /lib/ld-musl-x86_64.so.1 (0x7f2fdf705000)

v0.3.1:

# ldd node_modules/@libsql/linux-x64-musl/index.node 
	/lib/ld-musl-x86_64.so.1 (0x7f3343052000)
	libgcc_s.so.1 => /usr/lib/libgcc_s.so.1 (0x7f33423d0000)
	libc.so => /lib/ld-musl-x86_64.so.1 (0x7f3343052000)
Error relocating node_modules/@libsql/linux-x64-musl/index.node: __strcpy_chk: symbol not found
Error relocating node_modules/@libsql/linux-x64-musl/index.node: __memcpy_chk: symbol not found
Error relocating node_modules/@libsql/linux-x64-musl/index.node: __memset_chk: symbol not found
Error relocating node_modules/@libsql/linux-x64-musl/index.node: fcntl64: symbol not found

v0.3.2:

# ldd node_modules/@libsql/linux-x64-musl/index.node 
	/lib/ld-musl-x86_64.so.1 (0x7fb7d2869000)
	libgcc_s.so.1 => /usr/lib/libgcc_s.so.1 (0x7fb7d1be1000)
	libc.so => /lib/ld-musl-x86_64.so.1 (0x7fb7d2869000)
Error relocating node_modules/@libsql/linux-x64-musl/index.node: __strcpy_chk: symbol not found
Error relocating node_modules/@libsql/linux-x64-musl/index.node: fcntl64: symbol not found
Error relocating node_modules/@libsql/linux-x64-musl/index.node: __memcpy_chk: symbol not found
Error relocating node_modules/@libsql/linux-x64-musl/index.node: __memset_chk: symbol not found
Error relocating node_modules/@libsql/linux-x64-musl/index.node: fcntl64: symbol not found

Symbols such as __strcpy_chk are glibc-only and provided by its _FORTIFY_SOURCE feature.

Checking the commit history I suspect tursodatabase/libsql-js@e325e78 that introduced neon-bindings/neon-rs@9903c95 is a possible cause.

@yrke
Copy link

yrke commented Mar 1, 2024

As a workaround we downgrading from v5.x to v0.4.3 tested to work with node:18-alpine and node:20-alpine (at least for now)

penberg added a commit to tursodatabase/libsql-js that referenced this issue Mar 7, 2024
This reverts commit e325e78, which is
suspected to cause problems with musl:

tursodatabase/libsql-client-ts#180
@penberg
Copy link
Contributor

penberg commented Mar 7, 2024

Thanks for looking into this, @lovell! Unfortunately, the @neon-rs/cli bump was not related to the problem. Instead it's this libsql issue related to the new encryption feature: tursodatabase/libsql#1155

BrianUribe6 added a commit to jot-it/jotter that referenced this issue Mar 11, 2024
BrianUribe6 added a commit to jot-it/jotter that referenced this issue Mar 11, 2024
@penberg
Copy link
Contributor

penberg commented Mar 11, 2024

f61e2c1 should fix this.

@penberg penberg closed this as completed Mar 11, 2024
@lovell
Copy link

lovell commented Mar 11, 2024

Thanks for the updates, the fcntl64: symbol not found error remains with the new version when testing with latest Alpine Edge:

# cat node_modules/@libsql/linux-x64-musl/package.json | grep version
  "version": "0.3.9",

# ldd node_modules/@libsql/linux-x64-musl/index.node 
	/lib/ld-musl-x86_64.so.1 (0x76c8197f6000)
	libgcc_s.so.1 => /usr/lib/libgcc_s.so.1 (0x76c818f42000)
	libc.so => /lib/ld-musl-x86_64.so.1 (0x76c8197f6000)
Error relocating node_modules/@libsql/linux-x64-musl/index.node: fcntl64: symbol not found

The fcntl64 symbol is glibc-only and was introduced in glibc 2.28.

@RA9
Copy link

RA9 commented Mar 21, 2024

@lovell is the issue fixed?

@lovell
Copy link

lovell commented Mar 21, 2024

@RA9 This problem remains and now there are duplicate reports appearing e.g. tursodatabase/libsql-js#91

The summary is that the @libsql/linux-x64-musl package provided from v0.3.1 onwards, including the latest v0.3.10, does not work on musl-based systems.

@ruohki
Copy link

ruohki commented Mar 23, 2024

Ran into this problem while trying to build a astro application with the db integration. Wont build using node:lts-alpine

#0 2.037 node:internal/modules/cjs/loader:1473
#0 2.037   return process.dlopen(module, path.toNamespacedPath(filename));
#0 2.037                  ^
#0 2.037
#0 2.037 Error: Error relocating /app/node_modules/@libsql/linux-x64-musl/index.node: fcntl64: symbol not found
#0 2.037     at Module._extensions..node (node:internal/modules/cjs/loader:1473:18)
#0 2.037     at Module.load (node:internal/modules/cjs/loader:1207:32)
#0 2.037     at Module._load (node:internal/modules/cjs/loader:1023:12)
#0 2.037     at Module.require (node:internal/modules/cjs/loader:1235:19)
#0 2.037     at require (node:internal/modules/helpers:176:18)
#0 2.037     at Object.<anonymous> (/app/node_modules/libsql/index.js:42:5)
#0 2.037     at Module._compile (node:internal/modules/cjs/loader:1376:14)
#0 2.037     at Module._extensions..js (node:internal/modules/cjs/loader:1435:10)
#0 2.037     at Module.load (node:internal/modules/cjs/loader:1207:32)
#0 2.037     at Module._load (node:internal/modules/cjs/loader:1023:12) {
#0 2.037   code: 'ERR_DLOPEN_FAILED'
#0 2.037 }
#0 2.037
#0 2.037 Node.js v20.11.1

@flexchar
Copy link

flexchar commented Apr 7, 2024

@lovell does it mean we (Alpine users) must stick to v0.3.0 version?

@lovell
Copy link

lovell commented Apr 7, 2024

@flexchar That is my understanding, yes, but I'm only the messenger here. You'll need to ask one of the maintainers about the future possible re-introduction of support for musl-based Linux.

@IsaiahByDayah
Copy link

IsaiahByDayah commented Apr 17, 2024

Hey @penberg, should this issue be reopened? It doesn’t seem like the above proposed fix actually solved whatever the issue is for musl builds :/

@LukaGiorgadze
Copy link

Same problem.
/node_modules/@libsql/linux-x64-musl/index.node: fcntl64: symbol not found

node 18 alpine.

@steschi
Copy link

steschi commented Apr 23, 2024

@LukaGiorgadze not sure if it works for your setup, but I am using yarn v3 and as such can ensure I am using a version of libsql that works with alpine by adding this to the root package.json of my monorepo.

"resolutions": {
    "@libsql/linux-x64-musl@npm:0.3.15": "0.2.0"
},

For npm-users i guess overrides should be the equivalent -> https://docs.npmjs.com/cli/v10/configuring-npm/package-json#overrides

@MikeTeddyOmondi
Copy link

When is the release for this issue scheduled??
@penberg

@LukaGiorgadze
Copy link

@LukaGiorgadze not sure if it works for your setup, but I am using yarn v3 and as such can ensure I am using a version of libsql that works with alpine by adding this to the root package.json of my monorepo.

"resolutions": {
    "@libsql/linux-x64-musl@npm:0.3.15": "0.2.0"
},

For npm-users i guess overrides should be the equivalent -> https://docs.npmjs.com/cli/v10/configuring-npm/package-json#overrides

Tried, but did not work :/

@MikeTeddyOmondi
Copy link

@LukaGiorgadze
thats true .....

nichtsam added a commit to nichtsam/nichtsam.com that referenced this issue Jul 1, 2024
fix hanging querings
needed to switch image base because of
tursodatabase/libsql-client-ts#180
nichtsam added a commit to nichtsam/nichtsam.com that referenced this issue Jul 1, 2024
fix hanging querings
needed to switch image base because of
tursodatabase/libsql-client-ts#180
nichtsam added a commit to nichtsam/nichtsam.com that referenced this issue Jul 1, 2024
fix hanging querings
needed to switch image base because of
tursodatabase/libsql-client-ts#180
nichtsam added a commit to nichtsam/nichtsam.com that referenced this issue Jul 1, 2024
fix hanging querings
needed to switch image base because of
tursodatabase/libsql-client-ts#180
LucioFranco pushed a commit to tursodatabase/libsql-js that referenced this issue Aug 6, 2024
This reverts commit e325e78, which is
suspected to cause problems with musl:

tursodatabase/libsql-client-ts#180
@jeremybarbet
Copy link

Can this be reopened, because this issue is still happening

@jeremybarbet
Copy link

FYI, node-sqlite3 had the same issue and the fix for it

@erehwonmi
Copy link

Issue still persists up to this date

@brunodasilvalenga
Copy link

brunodasilvalenga commented Aug 29, 2024

Same here, getting the error in a nextjs app usign the @libsql/client version 0.6.0

5.703   ▲ Next.js 14.2.7
5.703   - Environments: .env
5.704
6.055    Creating an optimized production build ...
139.0  ✓ Compiled successfully
139.0    Linting and checking validity of types ...
199.6    Collecting page data ...
202.7 Error: Error relocating /app/node_modules/.pnpm/@libsql+linux-x64-musl@0.3.19/node_modules/@libsql/linux-x64-musl/index.node: fcntl64: symbol not found
202.7     at Module._extensions..node (node:internal/modules/cjs/loader:1340:18)
202.7     at Module.load (node:internal/modules/cjs/loader:1119:32)
202.7     at Module._load (node:internal/modules/cjs/loader:960:12)
202.7     at Module.require (node:internal/modules/cjs/loader:1143:19)
202.7     at mod.require (/app/node_modules/.pnpm/next@14.2.7_react-dom@18.3.1_react@18.3.1__react@18.3.1/node_modules/next/dist/server/require-hook.js:65:28)
202.7     at require (node:internal/modules/cjs/helpers:121:18)
202.7     at requireNative (/app/node_modules/.pnpm/libsql@0.3.19/node_modules/libsql/index.js:22:10)
202.7     at Object.<anonymous> (/app/node_modules/.pnpm/libsql@0.3.19/node_modules/libsql/index.js:42:5)
202.7     at Module._compile (node:internal/modules/cjs/loader:1256:14)
202.7     at Module._extensions..js (node:internal/modules/cjs/loader:1310:10) {
202.7   code: 'ERR_DLOPEN_FAILED'
202.7 }

@erehwonmi
Copy link

erehwonmi commented Aug 29, 2024

If some of you are using the Alpine distribution of Node for docker-izing an app with Libsql, I suggest migrating to the Bookworm distribution that fixed my issue and I can now use the latest version of libsql client. I am currently using Node 20 Bookworm for a docker-ized NextJS app with libsql client.

@jeremybarbet
Copy link

It's a workaround, but not a solution. Bookworm, bullseye or even distroless images work but are consuming more RAM compare to Alpine (15/20% more). In environment where you want to control cost on memory usage, Alpine is still the most optimised.

PS: You can probably use slim rather than the whole bookworm as well

@ahtcx
Copy link

ahtcx commented Sep 5, 2024

I'm getting this currently with libsql@0.4.1 and the alpine:latest Docker image.

@jonathannorris
Copy link

We are also getting this with the node:22.7-alpine3.20 docker image

@ahtcx
Copy link

ahtcx commented Sep 9, 2024

I resolved it by overriding @libsql/linux-x64-musl's version to be 0.2.0 as specified above, here's how I did this with pnpm.

{
	// ...
	"pnpm": {
		"overrides": {
			"@libsql/linux-x64-musl": "0.2.0"
		}
	}
}

@LucioFranco
Copy link
Contributor

I did some digging it looks like there were some larger issues with our Rust/C code that we built the js library (which TS uses). This PR should fix those issues and subsequent TS/Js issues tursodatabase/libsql#1724

@LucioFranco
Copy link
Contributor

v0.4.3 of libsql is out so if you run an npm update you should pick it up and should solve both the strcpy issue and the recent fcntl64 issues.

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