Open dylanblokhuis opened 1 year ago
So loading the binary works fine but trying to create Database object and using it results in segmentation fault? I don't have any Aarch64 Linux machine so this one would be hard to debug for me (VM is an option though).
Could you try building sqlite 3.40.1 locally and try using that binary?
I've managed to make SQLite3 ARM64 builds on CI but from my testing on QEMU locally, trying to load and call any SQLite lib function fails via Deno FFI regardless of its built in or custom built. This might be actually a problem with Deno (or its FFI) on ARM64. Anyhow, I'll try including Linux Arm64 binaries in next release, still worth trying out.
The custom-built SQLite works perfectly fine in QEMU Aarch64. This must be a problem with Deno FFI on Aarch64 because even a simple sqlite3_initialize
call doesn't work via FFI (but at the same time FFI is not completely broken either, I could call libc malloc easily). It's hard for me to debug this right now, I'll investigate this later.
I guess you can close this issue now, as since with newer version of sqlite3, at least >=3.41.2
, segfault doesn't appear
More info in here:
Oh that's great! I think we should update sqlite3 version in the repo now and publish new build for linux arm64. I'll try doing it over the weekend.
Interesting, it is still seg faulting for me on ArchLinux aarch64 VM.
Where did you get your deno and what version it is? I'm using this one:
deno 1.36.0 (release, aarch64-unknown-linux-gnu)
v8 11.6.189.12
typescript 5.1.6
Since it's not officially supported I humbly stole it from this great guy:
Got Deno for Linux aarch64 from the same place. SQLite 3.42.0 was built in CI using cross-compilation. Maybe that could be causing some issues. I'll try compiling it on the Linux VM itself.
Hi there, would love to help out with this issue. I have a Hetzner CAX21 aarch64 machine so I'm happy to test anything, and I'm decent at research/debugging/writing code. Currently, I can confirm sqlite 3.44.0 from debian unstable is not working (same issue, segfault). This was on Deno 1.38.2.
sid@arm-chan:~/shans-guestbook$ deno run -A --unstable src/main.ts
Segmentation fault
sid@arm-chan:~/shans-guestbook$ sqlite3 --version
3.44.0 2023-11-01 11:23:50 17129ba1ff7f0daf37100ee82d507aef7827cf38de1866e2633096ae6ad8alt1 (64-bit)
sid@arm-chan:~/shans-guestbook$ deno --version
deno 1.38.2 (release, aarch64-unknown-linux-gnu)
v8 12.0.267.1
typescript 5.2.2
sid@arm-chan:~/deno-ffi-test$ ls
add.c add.o ffi.ts libadd.so
sid@arm-chan:~/deno-ffi-test$ deno run --allow-ffi --unstable ffi.ts
Result from external addition of 35 and 34: 69
Can also confirm minimal example from https://docs.deno.com/runtime/manual/runtime/ffi_api works. Will be trying sqlite3 next.
@xyzshantaram did that work? You can try calling sqlite3_version function from both system sqlite and the sqlite aarch64 linux binary from GitHub releases in this repo, using Deno FFI.
#include <stdio.h>
#include <sqlite3.h>
void select_version() {
sqlite3 *db;
char *err_msg = 0;
int rc = sqlite3_open(":memory:", &db);
if (rc != SQLITE_OK) {
fprintf(stderr, "Cannot open database: %s\n", sqlite3_errmsg(db));
sqlite3_close(db);
return;
}
rc = sqlite3_exec(db, "SELECT SQLITE_VERSION()", 0, 0, &err_msg);
if (rc != SQLITE_OK) {
fprintf(stderr, "Failed to execute query: %s\n", sqlite3_errmsg(db));
sqlite3_free(err_msg);
} else {
printf("err_msg: %s\n", err_msg);
sqlite3_free(err_msg);
}
sqlite3_close(db);
}
While running this via FFI, err_msg
is null so I'm guessing this worked.
The system sqlite3 called via library segfaults as usual. Haven't tried the binary from releases yet.
Installed sqlite3
3.34.1
and ran:export DENO_SQLITE_PATH="/usr/lib/aarch64-linux-gnu/libsqlite3.so"
deno run -A --unstable app.ts
Result is a segfault when trying to use any sqlite3 functionality