prisma / quaint

SQL Query AST and Visitor for Rust
Apache License 2.0
582 stars 62 forks source link

Quaint seqfaults with empty SQLite commands #115

Closed rkapl closed 4 years ago

rkapl commented 4 years ago

Reproducer:

use quaint::pooled::Quaint;
use quaint::prelude::*;

#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error + Send + Sync>> {
    let q = Quaint::new("sqlite:test.db").await?;
    let c  = q.check_out().await?;
    c.execute_raw("", &[]).await?;
    Result::Ok(())
}

Backtrace:

  * frame #0: 0x00005555557bc69c quaint-test`sqlite3_clear_bindings(pStmt=0x0000000000000000) at sqlite3.c:81610:40
    frame #1: 0x000055555576df82 quaint-test`rusqlite::raw_statement::RawStatement::clear_bindings::h343c364d834a7c75(self=0x00007fffffff9d50) at raw_statement.rs:95:18
    frame #2: 0x00005555557717d5 quaint-test`rusqlite::cache::StatementCache::cache_stmt::h7a92c872dee251b7(self=0x0000555555a99250, stmt=(__0 = 0x0000000000000000)) at cache.rs:139:9
    frame #3: 0x000055555577137e quaint-test`_$LT$rusqlite..cache..CachedStatement$u20$as$u20$core..ops..drop..Drop$GT$::drop::h36e26cdc88cefec4(self=0x00007fffffff9f10) at cache.rs:86:13
    frame #4: 0x0000555555763977 quaint-test`core::ptr::drop_in_place::h920545ed40fe7c7a((null)=0x00007fffffff9f10) at mod.rs:177:1
    frame #5: 0x000055555562fd81 quaint-test`_$LT$quaint..connector..sqlite..Sqlite$u20$as$u20$quaint..connector..queryable..Queryable$GT$::execute_raw::_$u7b$$u7b$closure$u7d$$u7d$::_$u7b$$u7b$closure$u7d$$u7d$::h2fd5e94fff290f82 at sqlite.rs:205:13
    frame #6: 0x000055555562fea1 quaint-test`_$LT$quaint..connector..sqlite..Sqlite$u20$as$u20$quaint..connector..queryable..Queryable$GT$::execute_raw::_$u7b$$u7b$closure$u7d$$u7d$::h88ce23e985472900 at sqlite.rs:207:19
    frame #7: 0x00005555556108ae quaint-test`quaint::connector::metrics::query::_$u7b$$u7b$closure$u7d$$u7d$::h1fb49f99e7b8e4ec((null)=<unavailable>) at metrics.rs:19:19
    frame #8: 0x0000555555615cdf quaint-test`_$LT$std..future..GenFuture$LT$T$GT$$u20$as$u20$core..future..future..Future$GT$::poll::h9f2b432ea5ca4614(self=Pin<&mut std::future::GenFuture<generator-0>> @ 0x00007fffffffa720, cx=0x00007fffffffb5f0) at future.rs:44:15
    frame #9: 0x000055555563deb9 quaint-test`_$LT$quaint..connector..dbio..DBIO$LT$T$GT$$u20$as$u20$core..future..future..Future$GT$::poll::he066444a35b3d1db(self=Pin<&mut quaint::connector::dbio::DBIO<u64>> @ 0x00007fffffffa780, ctx=0x00007fffffffb5f0) at dbio.rs:25:9
    frame #10: 0x000055555561486d quaint-test`std::future::poll_with_tls_context::h64437bc63477017d(f=Pin<&mut quaint::connector::dbio::DBIO<u64>> @ 0x00007fffffffa818) at future.rs:99:14
    frame #11: 0x00005555555e59fe quaint-test`quaint_test::main::_$u7b$$u7b$closure$u7d$$u7d$::h17c3c46f3093e878((null)=<unavailable>) at main.rs:8:5
    frame #12: 0x00005555555e4702 quaint-test`_$LT$std..future..GenFuture$LT$T$GT$$u20$as$u20$core..future..future..Future$GT$::poll::h71fdd89390940c42(self=Pin<&mut std::future::GenFuture<generator-0>> @ 0x00007fffffffb390, cx=0x00007fffffffb5f0) at future.rs:44:15
    frame #13: 0x00005555555fc6b6 quaint-test`tokio::runtime::enter::Enter::block_on::_$u7b$$u7b$closure$u7d$$u7d$::h3e459cfe52175f05 at enter.rs:101:58
    frame #14: 0x00005555555bd6da quaint-test`tokio::coop::budget::_$u7b$$u7b$closure$u7d$$u7d$::h89bc075f7eb66002(hits=0x00007ffff7c0a2d8) at coop.rs:97:9
    frame #15: 0x00005555555d1d82 quaint-test`std::thread::local::LocalKey$LT$T$GT$::try_with::h3668363ab3b1f608(self=0x0000555555a27c38, f=closure-0 @ 0x00007fffffffb4f0) at local.rs:262:16
    frame #16: 0x00005555555d14fd quaint-test`std::thread::local::LocalKey$LT$T$GT$::with::hc82aeb690e204b0f(self=0x0000555555a27c38, f=closure-0 @ 0x00007fffffffb568) at local.rs:239:9
    frame #17: 0x00005555555fc543 quaint-test`tokio::runtime::enter::Enter::block_on::h7890a791e1399f56 [inlined] tokio::coop::budget::h28f55ca60abb5d42(f=closure-0 @ 0x00007fffffffb698) at coop.rs:79:5
    frame #18: 0x00005555555fc50f quaint-test`tokio::runtime::enter::Enter::block_on::h7890a791e1399f56(self=0x00007fffffffb6f0, f=(__0 = quaint_test::main::generator-0 @ 0x00007fffffffb710)) at enter.rs:101
    frame #19: 0x00005555555fec5f quaint-test`tokio::runtime::thread_pool::ThreadPool::block_on::h392433f9e3cb7450(self=0x00007fffffffd2e0, future=(__0 = quaint_test::main::generator-0 @ 0x00007fffffffc298)) at mod.rs:82:9
    frame #20: 0x00005555555bf699 quaint-test`tokio::runtime::Runtime::block_on::_$u7b$$u7b$closure$u7d$$u7d$::he2e7354750fff41d at mod.rs:420:39
    frame #21: 0x00005555555caa1e quaint-test`tokio::runtime::context::enter::hb24868dd9b9fc1a5(new=<unavailable>, f=closure-0 @ 0x00007fffffffcaf8) at context.rs:72:5
    frame #22: 0x00005555555d575b quaint-test`tokio::runtime::handle::Handle::enter::h6817f5ac891ddcb7(self=0x00007fffffffd380, f=closure-0 @ 0x00007fffffffcef0) at handle.rs:39:9
    frame #23: 0x00005555555bf5cd quaint-test`tokio::runtime::Runtime::block_on::h4a50a777093425e4(self=0x00007fffffffd2d8, future=<unavailable>) at mod.rs:415:9
    frame #24: 0x00005555555fca6f quaint-test`quaint_test::main::hc13577d9a723c273 at main.rs:4:1
    frame #25: 0x00005555555ce97b quaint-test`std::rt::lang_start::_$u7b$$u7b$closure$u7d$$u7d$::h1951a0cef2c0ae64 at rt.rs:67:34
    frame #26: 0x00005555558f3f2f quaint-test`std::rt::lang_start_internal::h0962c0aa989e5c64 [inlined] std::rt::lang_start_internal::_$u7b$$u7b$closure$u7d$$u7d$::he55e3739ea41259e at rt.rs:52:13
    frame #27: 0x00005555558f3f24 quaint-test`std::rt::lang_start_internal::h0962c0aa989e5c64 [inlined] std::panicking::try::do_call::h73e24f9817ae57df at panicking.rs:331
    frame #28: 0x00005555558f3f24 quaint-test`std::rt::lang_start_internal::h0962c0aa989e5c64 [inlined] std::panicking::try::hd08eb281999526b6 at panicking.rs:274
    frame #29: 0x00005555558f3f24 quaint-test`std::rt::lang_start_internal::h0962c0aa989e5c64 [inlined] std::panic::catch_unwind::hc981e5be87497715 at panic.rs:394
    frame #30: 0x00005555558f3f24 quaint-test`std::rt::lang_start_internal::h0962c0aa989e5c64 at rt.rs:51
    frame #31: 0x00005555555ce957 quaint-test`std::rt::lang_start::h252a346e8020a484(main=(quaint-test`quaint_test::main::hc13577d9a723c273 at main.rs:4), argc=1, argv=0x00007fffffffdf18) at rt.rs:67:5
    frame #32: 0x00005555555fcb1a quaint-test`main + 42
    frame #33: 0x00007ffff7d78023 libc.so.6`__libc_start_main + 243
    frame #34: 0x00005555555bd30e quaint-test`_start + 46
pimeys commented 4 years ago

So it passes the query down to the sqlite library, which panics with an empty query. We could

cryslith commented 4 years ago

I believe this is https://github.com/rusqlite/rusqlite/issues/583 which was fixed some time ago.

pimeys commented 4 years ago

I'll update it then.

-------- Original Message -------- On Apr 30, 2020, 09:14, Lily Chung wrote:

I believe this is rusqlite/rusqlite#583 which was fixed some time ago.

— You are receiving this because you were assigned. Reply to this email directly, view it on GitHub, or unsubscribe.

pimeys commented 4 years ago

Oh, this should be closed. We use rusqlite 0.21.