aboutsummaryrefslogtreecommitdiff
path: root/ext/wasm/api/sqlite3-api-glue.c-pp.js
diff options
context:
space:
mode:
authorstephan <stephan@noemail.net>2025-02-26 03:32:52 +0000
committerstephan <stephan@noemail.net>2025-02-26 03:32:52 +0000
commit69eaadbee3dc5912aba995288bfb20eeeb1222e6 (patch)
tree57dc2e0367a821171ea93add79f965300084042e /ext/wasm/api/sqlite3-api-glue.c-pp.js
parentd2f7dfa6190f529f7e543380b6663074e9078207 (diff)
parentd804893762174d23017921ddbf233fa90ae5015f (diff)
downloadsqlite-69eaadbee3dc5912aba995288bfb20eeeb1222e6.tar.gz
sqlite-69eaadbee3dc5912aba995288bfb20eeeb1222e6.zip
Merge trunk into the sahpool-digest branch.
FossilOrigin-Name: fc1eeb7d1f2880907b0fe71a8c572dd7cd74a5d65ec0177332976ad2f8c2b216
Diffstat (limited to 'ext/wasm/api/sqlite3-api-glue.c-pp.js')
-rw-r--r--ext/wasm/api/sqlite3-api-glue.c-pp.js37
1 files changed, 24 insertions, 13 deletions
diff --git a/ext/wasm/api/sqlite3-api-glue.c-pp.js b/ext/wasm/api/sqlite3-api-glue.c-pp.js
index bcaff7243..a40b83282 100644
--- a/ext/wasm/api/sqlite3-api-glue.c-pp.js
+++ b/ext/wasm/api/sqlite3-api-glue.c-pp.js
@@ -229,14 +229,15 @@ globalThis.sqlite3ApiBootstrap.initializers.push(function(sqlite3){
'*'
]],
/**
- 2025-02-03: We do not have a way to automatically clean up
- destructors which are automatically converted from JS functions
- via the final argument to sqlite3_set_auxdata(). Because of
- that, it is strongly recommended that clients use
- wasm.installFunction() to create such callbacks, then pass that
- pointer to sqlite3_set_auxdata(). Relying on automated
- conversions here will lead to leaks of JS/WASM proxy functions
- because sqlite3_set_auxdata() is frequently called in UDFs.
+ We do not have a way to automatically clean up destructors
+ which are automatically converted from JS functions via the
+ final argument to sqlite3_set_auxdata(). Because of that,
+ automatic function conversion is not supported for this
+ function. Clients should use wasm.installFunction() to create
+ such callbacks, then pass that pointer to
+ sqlite3_set_auxdata(). Relying on automated conversions here
+ would lead to leaks of JS/WASM proxy functions because
+ sqlite3_set_auxdata() is frequently called in UDFs.
The sqlite3.oo1.DB class's onclose handlers can be used for this
purpose. For example:
@@ -252,14 +253,24 @@ globalThis.sqlite3ApiBootstrap.initializers.push(function(sqlite3){
Then pass pAuxDtor as the final argument to appropriate
sqlite3_set_auxdata() calls.
+
+ Note that versions prior to 3.49.0 ostensibly had automatic
+ function conversion here but a typo prevented it from
+ working. Rather than fix it, it was removed because testing the
+ fix brought the huge potential for memory leaks to the
+ forefront.
*/
["sqlite3_set_auxdata", undefined, [
"sqlite3_context*", "int", "*",
- new wasm.xWrap.FuncPtrAdapter({
- name: 'xDestroyAuxData',
- signature: 'v(p)',
- contextKey: (argv, argIndex)=>argv[0/* sqlite3_context* */]
- })
+ true
+ ? "*"
+ : new wasm.xWrap.FuncPtrAdapter({
+ /* If we can find a way to automate their cleanup, JS functions can
+ be auto-converted with this. */
+ name: 'xDestroyAuxData',
+ signature: 'v(p)',
+ contextKey: (argv, argIndex)=>argv[0/* sqlite3_context* */]
+ })
]],
["sqlite3_shutdown", undefined],
["sqlite3_sourceid", "string"],