tursodatabase / libsql

libSQL is a fork of SQLite that is both Open Source, and Open Contributions.
https://turso.tech/libsql
MIT License
8.87k stars 235 forks source link

libsql+tokio doesn't work on windows - stack overflow #1051

Open dwilkolek opened 5 months ago

dwilkolek commented 5 months ago

I tried to use libsql (as per example) with tauri. It works flawlessly on linux and macos but it fails on windows. I think it's stuck somewhere in libsql::parser and smallvec, but I'm not certain. When I was going through the code base i went across those two references: https://github.com/gwenn/lemon-rs/issues/8 https://github.com/gwenn/lemon-rs/pull/19

Error:

thread 'main' has overflowed its stack
error: process didn't exit successfully: `target\debug\rust-pg.exe` (exit code: 0xc00000fd, STATUS_STACK_OVERFLOW)

main.rs

#[tokio::main]
async fn main() {
    let auth_token = String::from("token");
    let url = String::from("https://<turso-db>");

    let db = libsql::Builder::new_remote(url, auth_token)
        .build()
        .await
        .unwrap();

    let conn = db.connect().unwrap();

    let _result = conn.query(
            "SELECT name FROM users WHERE name = ?",
            libsql::params!["damian"],
        )
        .await;

}

Cargo.toml

[package]
name = "rust-pg"
version = "0.1.0"
edition = "2021"

# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

[dependencies]
tokio = { version = "1", features = ["full"] }
libsql = { git = "https://github.com/tursodatabase/libsql" }

[patch.crates-io]
sqlite3-parser = { git = "https://github.com/LucioFranco/lemon-rs" }
LucioFranco commented 5 months ago

Hi, we can take a look at this, but in the mean time you might be able to bump the stack size by setting this in a .cargo/config.toml

# 64 bit MSVC
[target.x86_64-pc-windows-msvc]
rustflags = [
    "-C", "link-arg=/STACK:8000000"
]

# 64 bit Mingw
[target.x86_64-pc-windows-gnu]
rustflags = [
    "-C", "link-arg=-Wl,--stack,8000000"
]
dwilkolek commented 5 months ago

I've set stack size for mvsc and it did work. Thank you! Let me know if there is anything I could do to help you out. 🙂

damccull commented 4 months ago

Please consider adding this info, or a link to this issue, to your official docs and mention Windows. I had this same error and it took 30 minutes of searching to find this.