limbo/extensions
Piotr Rzysko 977b6b331a Fix memory leak caused by unclosed virtual table cursors
The following code reproduces the leak, with memory usage increasing
over time:

```
#[tokio::main]
async fn main() {
    let db = Builder::new_local(":memory:").build().await.unwrap();
    let conn = db.connect().unwrap();

    conn.execute("SELECT load_extension('./target/debug/liblimbo_series');", ())
        .await
        .unwrap();

    loop {
        conn.execute("SELECT * FROM generate_series(1,10,2);", ())
            .await
            .unwrap();
    }
}
```

After switching to the system allocator, the leak becomes detectable
with Valgrind:

```
32,000 bytes in 1,000 blocks are definitely lost in loss record 24 of 24
   at 0x538580F: malloc (vg_replace_malloc.c:446)
   by 0x62E15FA: alloc::alloc::alloc (alloc.rs:99)
   by 0x62E172C: alloc::alloc::Global::alloc_impl (alloc.rs:192)
   by 0x62E1530: allocate (alloc.rs:254)
   by 0x62E1530: alloc::alloc::exchange_malloc (alloc.rs:349)
   by 0x62E0271: new<limbo_series::GenerateSeriesCursor> (boxed.rs:257)
   by 0x62E0271: open_GenerateSeriesVTab (lib.rs:19)
   by 0x425D8FA: limbo_core::VirtualTable::open (lib.rs:732)
   by 0x4285DDA: limbo_core::vdbe::execute::op_vopen (execute.rs:890)
   by 0x42351E8: limbo_core::vdbe::Program::step (mod.rs:396)
   by 0x425C638: limbo_core::Statement::step (lib.rs:610)
   by 0x40DB238: limbo::Statement::execute::{{closure}} (lib.rs:181)
   by 0x40D9EAF: limbo::Connection::execute::{{closure}} (lib.rs:109)
   by 0x40D54A1: example::main::{{closure}} (example.rs:26)
```

Interestingly, when using mimalloc, neither Valgrind nor mimalloc’s
internal statistics report the leak.
2025-05-05 21:26:23 +02:00
..
completion Implement xBestIndex for virtual table api to improve query planning 2025-04-17 13:53:27 -04:00
core Fix memory leak caused by unclosed virtual table cursors 2025-05-05 21:26:23 +02:00
crypto extensions/crypto: Fix mimalloc version 2025-02-18 20:05:10 +02:00
ipaddr Add ipaddr extension 2025-03-02 16:03:46 -05:00
percentile Merge 'Implement create virtual table using vtab modules, more work on virtual tables' from Preston Thorpe 2025-02-25 15:31:12 +02:00
regexp extensions/regexp: Fix mimalloc version 2025-02-18 20:06:43 +02:00
series Properly handle pushing predicates for query optimization from xBestIndex 2025-04-17 14:01:37 -04:00
tests Fix array from ptr in bestindex ffi method in proc macro 2025-04-17 14:01:45 -04:00
time extensions/time: normalize offset_sec 2025-02-19 21:25:14 +08:00
uuid Get name of argument for scalars in extensions to allow for less rigid naming 2025-03-01 14:27:33 -05:00