tursodatabase / libsql

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

use dedicated destroy_wal_manager function to destroy wal as it can be static #1514

Closed sivukhin closed 3 months ago

sivukhin commented 3 months ago

Context

TCL recoverfault tests are failing in master right now with the following error:

$> ./testfixture ext/recover/recoverfault.test
recoverfault-1.0... Ok
recoverfault-1-oom-persistent.1... Ok
recoverfault-1-oom-persistent.2... Ok
free(): invalid pointer
[1]    415207 IOT instruction (core dumped)  ./testfixture ext/recover/recoverfault.test

This is indeed happens due to the bug (rather minor - but still): if sqlite3MutexAlloc will fail during open call wal manager will be destroyed incorrectly with sqlite3_free function while it can be statically allocated.

Changes

Use dedicated destroy_wal_manager function which takes into account lifetime of the wal manager

Testing

Compiled testfixture and run it locally

MarinPostma commented 3 months ago

You need to generate the bundled bindings: "cargo xtask build-bundled" iirc