jssmith / ssqlite

Serverless SQLite Experiments
6 stars 3 forks source link

.open database with nfs4 loaded segfaults #1

Closed convolvatron closed 6 years ago

jssmith commented 6 years ago

I traced this segfault to os.c line 350

    if( strcmp(zVfs, pVfs->zName)==0 ) break;

It looks like something is wrong with the linked list but I'm not quite sure.

convolvatron commented 6 years ago

so if you dont specify ?vfs=nfs4 it dies in sqlite3PagerOpen, but the real issue is that pVfs is trash. the curious thing is that it shouldn't make a difference since nfs should be set up as the default after the .load

convolvatron commented 6 years ago

oh this is pretty whack, .open is calling dlclose, so the vfs we registered no longer exists

thats brilliant. unix vfs is unloading the extension..because we loaded it as part of the current database...clearly this use case hasn't been really thought out. will try to come up with a strategy

convolvatron commented 6 years ago

fixed in write_status

  1. Persistent Loadable Extensions

The default behavior for a loadable extension is that it is unloaded from process memory when the database connection that originally invoked sqlite3_load_extension() closes. (In other words, the xDlUnload method of the sqlite3_vfs object is called for all extensions when a database connection closes.) However, if the initialization procedure returns SQLITE_OK_LOAD_PERMANENTLY instead of SQLITE_OK, then the extension will not be unloaded (xDlClose will not be invoked) and the extension will remain in process memory indefinitely. The SQLITE_OK_LOAD_PERMANENTLY return value is useful for extensions that want to register new VFSes.

jssmith commented 6 years ago

Great, this appears to be resolved.