-
Notifications
You must be signed in to change notification settings - Fork 1
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
sqlite3 aborted: free(): double free detected in tcache 2 #7
Comments
Same issue with the sample provided. % sqlite3 test2.db SQLite version 3.27.2 2019-02-25 16:06:06 sqlite> .load ./pivot_vtab sqlite> CREATE TABLE r AS ...> SELECT 1 id UNION SELECT 2 UNION SELECT 3; sqlite> CREATE TABLE c( ...> id INTEGER PRIMARY KEY, ...> name TEXT ...> ); sqlite> INSERT INTO c (name) VALUES ...> ('a'),('b'),('c'),('d'); sqlite> CREATE TABLE x( ...> r_id INT, ...> c_id INT, ...> val TEXT ...> ); sqlite> INSERT INTO x (r_id, c_id, val) ...> SELECT r.id, c.id, c.name || r.id ...> FROM c, r; sqlite> CREATE VIRTUAL TABLE pivot USING pivot_vtab( ...> (SELECT id r_id -- pivot table key ...> FROM r), ...> (SELECT id c_id, -- pivot column key - can be referenced in pivot query as ?2 ...> name -- pivot column name ...> FROM c), ...> (SELECT val ...> FROM x ...> WHERE r_id = ?1 ...> AND c_id = ?2) ...> ); sqlite> SELECT * ...> FROM pivot; r_id a b c d ---- ----- ----- ----- ----- 1 a1 b1 c1 d1 2 a2 b2 c2 d2 3 a3 b3 c3 d3 free(): double free detected in tcache 2 [1] 16982 abort sqlite3 test2.db |
Line 479 appears to trigger the error: freeing the pivot key. % gdb sqlite3 ... sqlite> .load ./pivot_vtab sqlite> select * from pivot; r_id a b c d ---------- ---------- ---------- ---------- ---------- 1 a1 b1 c1 d1 2 a2 b2 c2 d2 3 a3 b3 c3 d3 Breakpoint 1, pivotClose (pCur=0x51e1a0) at pivot_vtab.c:472 472 pivot_vtab *tab = (pivot_vtab*)pCur->pVtab; (gdb) n 473 pivot_cursor *cur = (pivot_cursor*)pCur; (gdb) 476 if( cur->pivot_key ){ (gdb) 477 for( i=0; inRow_cols; i++ ) (gdb) 478 sqlite3_value_free(cur->pivot_key[i]); (gdb) print i $1 = 0 (gdb) p cur->pivot_key[i] $2 = (sqlite3_value *) 0x0 (gdb) p tab->nRow_cols $3 = 1 (gdb) p cur->pivot_key $4 = (sqlite3_value **) 0x519c28 (gdb) n 477 for( i=0; inRow_cols; i++ ) (gdb) n 479 sqlite3_free(cur->pivot_key); (gdb) p cur->pivot_key $5 = (sqlite3_value **) 0x519c28 (gdb) n free(): double free detected in tcache 2 Program received signal SIGABRT, Aborted. |
rwaldura
changed the title
free(): double free detected in tcache 2
sqlite3 aborted: free(): double free detected in tcache 2
Mar 10, 2023
Commenting out line 479 appears to fix it... but it hardly seems satisfying. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Terminal failure on simple example pulled from https://antonz.org/sqlite-pivot-table/.
Am I doing it wrong?
The text was updated successfully, but these errors were encountered: