mirror of
https://github.com/sqlite/sqlite.git
synced 2025-07-27 20:41:58 +03:00
Improve the JS-side sqlite3_set_auxdata() test to also trigger the case that the aux data actually gets reused. Test changes only, no library code.
FossilOrigin-Name: 9f27379d860518e6e097a2c999da04176812260a61bf11fe495c3efd76971806
This commit is contained in:
@ -3445,7 +3445,6 @@ globalThis.sqlite3InitModule = sqlite3InitModule;
|
|||||||
const stack = wasm.pstack.pointer;
|
const stack = wasm.pstack.pointer;
|
||||||
const pAux = wasm.pstack.alloc(4);
|
const pAux = wasm.pstack.alloc(4);
|
||||||
let pAuxDestructed = 0;
|
let pAuxDestructed = 0;
|
||||||
const args = [];
|
|
||||||
const pAuxDtor = wasm.installFunction('v(p)', function(ptr){
|
const pAuxDtor = wasm.installFunction('v(p)', function(ptr){
|
||||||
//log("freeing auxdata");
|
//log("freeing auxdata");
|
||||||
++pAuxDestructed;
|
++pAuxDestructed;
|
||||||
@ -3457,10 +3456,11 @@ globalThis.sqlite3InitModule = sqlite3InitModule;
|
|||||||
wasm.uninstallFunction(pAuxDtor);
|
wasm.uninstallFunction(pAuxDtor);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
let nAuxSet = 0 /* how many times we set aux data */;
|
||||||
|
let nAuxReused = 0 /* how many times we reused aux data */;
|
||||||
try{
|
try{
|
||||||
db.createFunction("auxtest",{
|
db.createFunction("auxtest",{
|
||||||
xFunc: function(pCx, x, y){
|
xFunc: function(pCx, x, y){
|
||||||
args.push(x);
|
|
||||||
T.assert(wasm.isPtr(pCx));
|
T.assert(wasm.isPtr(pCx));
|
||||||
const localAux = capi.sqlite3_get_auxdata(pCx, 0);
|
const localAux = capi.sqlite3_get_auxdata(pCx, 0);
|
||||||
if( !localAux ){
|
if( !localAux ){
|
||||||
@ -3477,15 +3477,12 @@ globalThis.sqlite3InitModule = sqlite3InitModule;
|
|||||||
pointer this function, and cleanup (at some point)
|
pointer this function, and cleanup (at some point)
|
||||||
using wasm.uninstallFunction().
|
using wasm.uninstallFunction().
|
||||||
*/
|
*/
|
||||||
|
++nAuxSet;
|
||||||
capi.sqlite3_set_auxdata(pCx, 0, pAux, pAuxDtor);
|
capi.sqlite3_set_auxdata(pCx, 0, pAux, pAuxDtor);
|
||||||
}else{
|
}else{
|
||||||
/* This is never actually hit in this example and it's
|
//log("reusing auxdata",localAux);
|
||||||
not entirely clear how to cause it to. The point of
|
|
||||||
this test, however, is to demonstrate that the
|
|
||||||
finalizer impl gets triggered, so we're not going to
|
|
||||||
fret over this at the moment. */
|
|
||||||
//log("seen auxdata",localAux);
|
|
||||||
T.assert(pAux===localAux);
|
T.assert(pAux===localAux);
|
||||||
|
++nAuxReused;
|
||||||
}
|
}
|
||||||
return x;
|
return x;
|
||||||
}
|
}
|
||||||
@ -3493,13 +3490,14 @@ globalThis.sqlite3InitModule = sqlite3InitModule;
|
|||||||
db.exec([
|
db.exec([
|
||||||
"create table t(a);",
|
"create table t(a);",
|
||||||
"insert into t(a) values(1),(2),(3);",
|
"insert into t(a) values(1),(2),(3);",
|
||||||
"select auxtest(a,a), auxtest(a,a) from t order by a"
|
"select auxtest(1,a), auxtest(1,a) from t order by a"
|
||||||
]);
|
]);
|
||||||
}finally{
|
}finally{
|
||||||
db.close();
|
db.close();
|
||||||
wasm.pstack.restore(stack);
|
wasm.pstack.restore(stack);
|
||||||
}
|
}
|
||||||
T.assert(6===args.length);
|
T.assert(nAuxSet>0).assert(nAuxReused>0)
|
||||||
|
.assert(6===nAuxReused+nAuxSet);
|
||||||
T.assert(pAuxDestructed>0);
|
T.assert(pAuxDestructed>0);
|
||||||
T.assert(pAuxDtorDestructed);
|
T.assert(pAuxDtorDestructed);
|
||||||
}
|
}
|
||||||
|
12
manifest
12
manifest
@ -1,5 +1,5 @@
|
|||||||
C Rework\s[76c8435a]\sto\seliminate\sautomatic\sJS-to-WASM\sfunction\sconversions\sof\ssqlite3_set_auxdata()\sdestructors\sbecause\sit\scan\sleads\sto\sleaks\son\severy\scall\sof\sa\sUDF.\sThis\sfeature\snever\sworked\sbefore\s[76c8435a]\sbut\sfixing\sit\swas\sill-conceived\sbecause\sof\sthe\smemory\sleakage\sit\sintroduces.\sWASM\sfunction\spointers\scan\sstill\sbe\sused\sas\sdestructors\sin\sthis\scontext.
|
C Improve\sthe\sJS-side\ssqlite3_set_auxdata()\stest\sto\salso\strigger\sthe\scase\sthat\sthe\saux\sdata\sactually\sgets\sreused.\sTest\schanges\sonly,\sno\slibrary\scode.
|
||||||
D 2025-02-03T17:34:12.962
|
D 2025-02-03T18:01:42.876
|
||||||
F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1
|
F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1
|
||||||
F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea
|
F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea
|
||||||
F LICENSE.md e108e1e69ae8e8a59e93c455654b8ac9356a11720d3345df2a4743e9590fb20d
|
F LICENSE.md e108e1e69ae8e8a59e93c455654b8ac9356a11720d3345df2a4743e9590fb20d
|
||||||
@ -696,7 +696,7 @@ F ext/wasm/test-opfs-vfs.html 1f2d672f3f3fce810dfd48a8d56914aba22e45c6834e262555
|
|||||||
F ext/wasm/test-opfs-vfs.js 1618670e466f424aa289859fe0ec8ded223e42e9e69b5c851f809baaaca1a00c
|
F ext/wasm/test-opfs-vfs.js 1618670e466f424aa289859fe0ec8ded223e42e9e69b5c851f809baaaca1a00c
|
||||||
F ext/wasm/tester1-worker.html ebc4b820a128963afce328ecf63ab200bd923309eb939f4110510ab449e9814c
|
F ext/wasm/tester1-worker.html ebc4b820a128963afce328ecf63ab200bd923309eb939f4110510ab449e9814c
|
||||||
F ext/wasm/tester1.c-pp.html 1c1bc78b858af2019e663b1a31e76657b73dc24bede28ca92fbe917c3a972af2
|
F ext/wasm/tester1.c-pp.html 1c1bc78b858af2019e663b1a31e76657b73dc24bede28ca92fbe917c3a972af2
|
||||||
F ext/wasm/tester1.c-pp.js 45000532cf83f23a52b31581c1db44bfb82e383b1b68703ae4d3d838de3a833e
|
F ext/wasm/tester1.c-pp.js 05a0143c44a4114aad0ed40ce73c528febc3e0d6b69f48a51c895d7030015b74
|
||||||
F ext/wasm/tests/opfs/concurrency/index.html 657578a6e9ce1e9b8be951549ed93a6a471f4520a99e5b545928668f4285fb5e
|
F ext/wasm/tests/opfs/concurrency/index.html 657578a6e9ce1e9b8be951549ed93a6a471f4520a99e5b545928668f4285fb5e
|
||||||
F ext/wasm/tests/opfs/concurrency/test.js d08889a5bb6e61937d0b8cbb78c9efbefbf65ad09f510589c779b7cc6a803a88
|
F ext/wasm/tests/opfs/concurrency/test.js d08889a5bb6e61937d0b8cbb78c9efbefbf65ad09f510589c779b7cc6a803a88
|
||||||
F ext/wasm/tests/opfs/concurrency/worker.js 0a8c1a3e6ebb38aabbee24f122693f1fb29d599948915c76906681bb7da1d3d2
|
F ext/wasm/tests/opfs/concurrency/worker.js 0a8c1a3e6ebb38aabbee24f122693f1fb29d599948915c76906681bb7da1d3d2
|
||||||
@ -2209,8 +2209,8 @@ F tool/version-info.c 3b36468a90faf1bbd59c65fd0eb66522d9f941eedd364fabccd7227350
|
|||||||
F tool/warnings-clang.sh bbf6a1e685e534c92ec2bfba5b1745f34fb6f0bc2a362850723a9ee87c1b31a7
|
F tool/warnings-clang.sh bbf6a1e685e534c92ec2bfba5b1745f34fb6f0bc2a362850723a9ee87c1b31a7
|
||||||
F tool/warnings.sh 49a486c5069de041aedcbde4de178293e0463ae9918ecad7539eedf0ec77a139
|
F tool/warnings.sh 49a486c5069de041aedcbde4de178293e0463ae9918ecad7539eedf0ec77a139
|
||||||
F tool/win/sqlite.vsix deb315d026cc8400325c5863eef847784a219a2f
|
F tool/win/sqlite.vsix deb315d026cc8400325c5863eef847784a219a2f
|
||||||
P d693c2dddbd10a2e0b77893b04b11502e30b768f1b06814105f7f35172845fb9
|
P 3fb993af0caf041da934cea29c039b27c468be0b75bce1537a6425767cf9bf8d
|
||||||
R bdcc5096cc30e3d83fdf5d66602909e7
|
R b579198e5351884de756285222a8e6ad
|
||||||
U stephan
|
U stephan
|
||||||
Z fd720e9f1383b7c5da4643ab36634ed7
|
Z a4679fe65a08b67080b3faca6c413001
|
||||||
# Remove this line to create a well-formed Fossil manifest.
|
# Remove this line to create a well-formed Fossil manifest.
|
||||||
|
@ -1 +1 @@
|
|||||||
3fb993af0caf041da934cea29c039b27c468be0b75bce1537a6425767cf9bf8d
|
9f27379d860518e6e097a2c999da04176812260a61bf11fe495c3efd76971806
|
||||||
|
Reference in New Issue
Block a user