From: stephan Date: Sun, 16 Mar 2025 14:05:42 +0000 (+0000) Subject: Fix a long-standing filename digest computation bug in the OPFS SAHPool VFS which... X-Git-Tag: major-release~185 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=d176ef5881c2dc9e468c81749a3421e3fa0751e9;p=thirdparty%2Fsqlite.git Fix a long-standing filename digest computation bug in the OPFS SAHPool VFS which caused all VFS-stored filenames to have a digest value of 0. See [/forumpost/042d53c928382021] and for full details. FossilOrigin-Name: 493cbe74504e8eb1ca8f2edf49fdab6bebc7fe36ffab06932a4b8c5a4eea86cd --- d176ef5881c2dc9e468c81749a3421e3fa0751e9 diff --cc ext/wasm/api/sqlite3-vfs-opfs-sahpool.c-pp.js index 95843a35dc,f30df31985..73426f2039 --- a/ext/wasm/api/sqlite3-vfs-opfs-sahpool.c-pp.js +++ b/ext/wasm/api/sqlite3-vfs-opfs-sahpool.c-pp.js @@@ -633,6 -677,6 +677,7 @@@ globalThis.sqlite3ApiBootstrap.initiali // leaving stale db data laying around. sah.truncate(HEADER_OFFSET_DATA); } ++ //warn("getAssociatedPath() flags",'0x'+flags.toString(16), "compDigest", compDigest,"pathBytes",pathBytes); return pathBytes ? textDecoder.decode(this.#apBody.subarray(0,pathBytes)) : ''; diff --cc ext/wasm/tests/opfs/sahpool/digest-worker.js index 0000000000,4308566675..28b3c1673f mode 000000,100644..100644 --- a/ext/wasm/tests/opfs/sahpool/digest-worker.js +++ b/ext/wasm/tests/opfs/sahpool/digest-worker.js @@@ -1,0 -1,94 +1,94 @@@ + /* + 2025-01-31 + + The author disclaims copyright to this source code. In place of a + legal notice, here is a blessing: + + * May you do good and not evil. + * May you find forgiveness for yourself and forgive others. + * May you share freely, never taking more than you give. + + *********************************************************************** + - This file is part of sahpool-pausing.js's demonstration of the - pause/unpause feature of the opfs-sahpool VFS. ++ This file is part of testing the OPFS SAHPool VFS's computeDigest() ++ fix. See ./digest.html for the details. + */ + const clog = console.log.bind(console); + const wPost = (type,...args)=>postMessage({type, payload:args}); + const log = (...args)=>{ + clog("Worker:",...args); + wPost('log',...args); + } + + const hasOpfs = ()=>{ + return globalThis.FileSystemHandle + && globalThis.FileSystemDirectoryHandle + && globalThis.FileSystemFileHandle + && globalThis.FileSystemFileHandle.prototype.createSyncAccessHandle + && navigator?.storage?.getDirectory; + }; + if( !hasOpfs() ){ + wPost('error',"OPFS not detected"); + throw new Error("OPFS not detected"); + } + + clog("Importing sqlite3..."); + const searchParams = new URL(self.location.href).searchParams; + importScripts(searchParams.get('sqlite3.dir') + '/sqlite3.js'); + + const runTests = function(sqlite3, poolUtil){ + const fname = '/my.db'; + let db = new poolUtil.OpfsSAHPoolDb(fname); + let n = (new Date()).valueOf(); + try { + db.exec([ + "create table if not exists t(a);" + ]); + db.exec({ + sql: "insert into t(a) values(?)", + bind: n++ + }); + log(fname,"record count: ",db.selectValue("select count(*) from t")); + }finally{ + db.close(); + } + + db = new poolUtil.OpfsSAHPoolDb(fname); + try { + db.exec({ + sql: "insert into t(a) values(?)", + bind: n++ + }); + log(fname,"record count: ",db.selectValue("select count(*) from t")); + }finally{ + db.close(); + } + + const fname2 = '/my2.db'; + db = new poolUtil.OpfsSAHPoolDb(fname2); + try { + db.exec([ + "create table if not exists t(a);" + ]); + db.exec({ + sql: "insert into t(a) values(?)", + bind: n++ + }); + log(fname2,"record count: ",db.selectValue("select count(*) from t")); + }finally{ + db.close(); + } + }; + + globalThis.sqlite3InitModule().then(async function(sqlite3){ + log("sqlite3 version:",sqlite3.version); + const sahPoolConfig = { + name: 'opfs-sahpool-digest', + clearOnInit: false, + initialCapacity: 6 + }; + return sqlite3.installOpfsSAHPoolVfs(sahPoolConfig).then(poolUtil=>{ + log('vfs acquired'); + runTests(sqlite3, poolUtil); + }); + }); diff --cc ext/wasm/tests/opfs/sahpool/digest.html index 0000000000,fdcd98ec13..daa1f77287 mode 000000,100644..100644 --- a/ext/wasm/tests/opfs/sahpool/digest.html +++ b/ext/wasm/tests/opfs/sahpool/digest.html @@@ -1,0 -1,141 +1,151 @@@ + + + + + + + + + sqlite3 tester: OpfsSAHPool Digest + + +

+ +

+ This is a test app for the digest calculation of the OPFS + SAHPool VFS. It requires running it with a new database created using + v3.49.0 or older, then running it again with a newer version, then + again with 3.49.0 or older. +

+
+ + +
+
+ + + diff --cc manifest index 6fe3756f0f,27398cb278..ea7d2d3b75 --- a/manifest +++ b/manifest @@@ -1,5 -1,5 +1,5 @@@ - C Add\s--asan-fsanitize=...\sconfigure\sflag\sto\sthe\scanonical\sbuild\sto\soptionally\sset\s-fsantize\sflags\sfor\sthe\sfuzzcheck-asan\stool.\sTeach\sproj-check-fsanitiz\sto\sfail\sfor\sflags\swhich\sthe\scompiler\semits\sany\swarning\sfor,\sfor\sreasons\sdescribed\sin\sits\scomments. - D 2025-03-16T13:09:21.699 -C Minor\sdoc\scorrections\sfor\sthe\ssahpool-digest\sfix\sand\smerge\sin\scurrent\strunk. -D 2025-03-14T11:14:52.385 ++C Fix\sa\slong-standing\sfilename\sdigest\scomputation\sbug\sin\sthe\sOPFS\sSAHPool\sVFS\swhich\scaused\sall\sVFS-stored\sfilenames\sto\shave\sa\sdigest\svalue\sof\s0.\sSee\s[/forumpost/042d53c928382021]\sand\sfor\sfull\sdetails. ++D 2025-03-16T14:05:42.209 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F LICENSE.md e108e1e69ae8e8a59e93c455654b8ac9356a11720d3345df2a4743e9590fb20d @@@ -645,7 -645,7 +645,7 @@@ F ext/wasm/api/sqlite3-api-worker1.c-pp F ext/wasm/api/sqlite3-license-version-header.js 0c807a421f0187e778dc1078f10d2994b915123c1223fe752b60afdcd1263f89 F ext/wasm/api/sqlite3-opfs-async-proxy.js 9654b565b346dc609b75d15337f20acfa7af7d9d558da1afeb9b6d8eaa404966 F ext/wasm/api/sqlite3-vfs-helper.c-pp.js 3f828cc66758acb40e9c5b4dcfd87fd478a14c8fb7f0630264e6c7fa0e57515d - F ext/wasm/api/sqlite3-vfs-opfs-sahpool.c-pp.js 16d80af915bfd2529824b999b304425503094eedf34fb113d0791e002b13e5cf -F ext/wasm/api/sqlite3-vfs-opfs-sahpool.c-pp.js 25d51a69084931c909a11e6850761ee156d9e243f733a42b221f3f90d70bd5ee ++F ext/wasm/api/sqlite3-vfs-opfs-sahpool.c-pp.js 0f68a64e508598910e7c01214ae27d603dfc8baec6a184506fafac603a901931 F ext/wasm/api/sqlite3-vfs-opfs.c-pp.js 4ab0704ee198de7d1059eccedc7703c931510b588d10af0ee36ea5b3ebbac284 F ext/wasm/api/sqlite3-vtab-helper.c-pp.js e809739d71e8b35dfe1b55d24d91f02d04239e6aef7ca1ea92a15a29e704f616 F ext/wasm/api/sqlite3-wasm.c 6a4cd40267eaf08400895c5b9de39c56976c3b97b3c1bbe53fc2e80fa074e9c7 @@@ -700,6 -700,8 +700,8 @@@ F ext/wasm/tester1.c-pp.js 419717b16e12 F ext/wasm/tests/opfs/concurrency/index.html 657578a6e9ce1e9b8be951549ed93a6a471f4520a99e5b545928668f4285fb5e F ext/wasm/tests/opfs/concurrency/test.js d08889a5bb6e61937d0b8cbb78c9efbefbf65ad09f510589c779b7cc6a803a88 F ext/wasm/tests/opfs/concurrency/worker.js 0a8c1a3e6ebb38aabbee24f122693f1fb29d599948915c76906681bb7da1d3d2 -F ext/wasm/tests/opfs/sahpool/digest-worker.js f8320caaf6368ee8c59f259de5bebe68232f678390dc773ee61c466e171881dc -F ext/wasm/tests/opfs/sahpool/digest.html 08122dabf8ef56ac7d40f43660e178811166842bb47b37cbb11003030bb9ce09 ++F ext/wasm/tests/opfs/sahpool/digest-worker.js b0ab6218588f1f0a6d15a363b493ceaf29bfb87804d9e0165915a9996377cf79 ++F ext/wasm/tests/opfs/sahpool/digest.html 206d08a34dc8bd570b2581d3d9ab3ecad3201b516a598dd096dcf3cf8cd81df8 F ext/wasm/tests/opfs/sahpool/index.html be736567fd92d3ecb9754c145755037cbbd2bca01385e2732294b53f4c842328 F ext/wasm/tests/opfs/sahpool/sahpool-pausing.js f264925cfc82155de38cecb3d204c36e0f6991460fff0cb7c15079454679a4e2 F ext/wasm/tests/opfs/sahpool/sahpool-worker.js bd25a43fc2ab2d1bafd8f2854ad3943ef673f7c3be03e95ecf1612ff6e8e2a61 @@@ -2213,8 -2215,8 +2215,9 @@@ F tool/version-info.c 3b36468a90faf1bbd F tool/warnings-clang.sh bbf6a1e685e534c92ec2bfba5b1745f34fb6f0bc2a362850723a9ee87c1b31a7 F tool/warnings.sh 49a486c5069de041aedcbde4de178293e0463ae9918ecad7539eedf0ec77a139 F tool/win/sqlite.vsix deb315d026cc8400325c5863eef847784a219a2f - P be3a2e631100b711996b9524a54fc604966513a62d83fc916270a6226da7adab - R 699bb2f6a1869a511409b94aecd9b45c -P fc1eeb7d1f2880907b0fe71a8c572dd7cd74a5d65ec0177332976ad2f8c2b216 f786de8d1873cd27b1bf83273a1e100e9d481144674888ccf65974e003a3caad -R 1281ce5a1bf5b175e155c185d7f4bb6f ++P 013730e9b92af39cb7fd2871df9b4bc81b8990f918892bd79370704421672da0 500f2e6ec74b4c0e4ac0365ba4e0d81ed6df8dd09dc0f8af65d294c3453f8865 ++R 9266ed4d88e1ccecb16602d4a66164a0 ++T +closed 500f2e6ec74b4c0e4ac0365ba4e0d81ed6df8dd09dc0f8af65d294c3453f8865 Closed\sby\sintegrate-merge. U stephan - Z b465670c31108cfd99bca4e96066f044 -Z f4da5ec6a61829129290a8d77df27ca0 ++Z 8dfe9f7d9c954162ba84353f5fc2343c # Remove this line to create a well-formed Fossil manifest. diff --cc manifest.uuid index fec909f33f,0d969c256a..3d3dbbdd32 --- a/manifest.uuid +++ b/manifest.uuid @@@ -1,1 -1,1 +1,1 @@@ - 013730e9b92af39cb7fd2871df9b4bc81b8990f918892bd79370704421672da0 -500f2e6ec74b4c0e4ac0365ba4e0d81ed6df8dd09dc0f8af65d294c3453f8865 ++493cbe74504e8eb1ca8f2edf49fdab6bebc7fe36ffab06932a4b8c5a4eea86cd