Hello,
I have been struggling with a segfault when trying to use an sqlite fts extension that I found here : https://github.com/illarionov/sqlite3-unicodesn
The extension worked like a charm when I compiled it direcly against my compiled sqlite3 ; but when I used it with node-sqlite3 it segfaulted.
At first I thought it was an sqlite version compatibility issue so I recompiled the extension against the sqlite3 packaged with node-sqlite3. Still a segfault.
It was weird because the fts4_rank extension mentioned on node-sqlite3 website ran ok with the same build chain.
I tried to compile both node-sqlite3 and my extension with the same sqlite3 as a static library. It worked better but segfaulted later because the global sqlite3Config variable was initialized in one static sqlite3 but not in the other.
At this point it was clear I needed to have both node-sqlite3 & my extension built against the same sqlite, but both using sqlite3 as a shared library.
After a while, I found and decided to use the --build-from-source combined with the --sqlite= option. This chain make sqlite3 used as a shared library.
It worked a bit better, node-sqlite3 was not crashing anymore.
Nevertheless when executing a query against the tokenizer it was complaining :
{ [Error: SQLITE_ERROR: no such module: fts4] errno: 1, code: 'SQLITE_ERROR' }
My system is a CentOS 6.x and node-sqlite3 was using at runtime the libsqlite3.so of the system instead of my custom sqlite3 (the system has an old version of sqlite)
So I needed to have node-sqlite3 use at runtime my custom sqlite3 library.
This was solved by adding a :
'conditions': [ [ 'OS!="mac"', {'libraries+':['-Wl,-rpath=<@(sqlite)/lib']} ] ](inspired from https://github.com/couchbase/couchnode/blob/master/binding.gyp)
in the "external" condition of the binding.gyp
now everything is working fine :-)
I am wondering if this rpath= linker flag should not be committed to binding.gyp. I don't see a reason why people would like to link against their own version of sqlite3 at compile time with the --sqlite flag and not link with this version also at runtime.
currently my node-sqlite3 install process is :
npm install --build-from-source --sqlite=/path/to/custom/sqlite3 sqlite3
edit binding.gyp internal to add the new line above
npm rebuild --build-from-source --sqlite=/path/to/custom/sqlite3 sqlite3
if you could add the rpath 'libraries+' line in the binding.gyp, the install process could be streamlined to just
npm install --build-from-source --sqlite=/path/to/custom/sqlite3 sqlite3
Tell me if you think you could accept this modification to binding.gyp ("external" branch).
ps: congrats on the binding implementation ! modern c++ as advertised :-)
Hello,
I have been struggling with a segfault when trying to use an sqlite fts extension that I found here : https://github.com/illarionov/sqlite3-unicodesn
The extension worked like a charm when I compiled it direcly against my compiled sqlite3 ; but when I used it with node-sqlite3 it segfaulted.
At first I thought it was an sqlite version compatibility issue so I recompiled the extension against the sqlite3 packaged with node-sqlite3. Still a segfault.
It was weird because the fts4_rank extension mentioned on node-sqlite3 website ran ok with the same build chain.
I tried to compile both node-sqlite3 and my extension with the same sqlite3 as a static library. It worked better but segfaulted later because the global sqlite3Config variable was initialized in one static sqlite3 but not in the other.
At this point it was clear I needed to have both node-sqlite3 & my extension built against the same sqlite, but both using sqlite3 as a shared library.
After a while, I found and decided to use the --build-from-source combined with the --sqlite= option. This chain make sqlite3 used as a shared library.
It worked a bit better, node-sqlite3 was not crashing anymore.
Nevertheless when executing a query against the tokenizer it was complaining :
{ [Error: SQLITE_ERROR: no such module: fts4] errno: 1, code: 'SQLITE_ERROR' }
My system is a CentOS 6.x and node-sqlite3 was using at runtime the libsqlite3.so of the system instead of my custom sqlite3 (the system has an old version of sqlite)
So I needed to have node-sqlite3 use at runtime my custom sqlite3 library.
This was solved by adding a :
'conditions': [ [ 'OS!="mac"', {'libraries+':['-Wl,-rpath=<@(sqlite)/lib']} ] ](inspired from https://github.com/couchbase/couchnode/blob/master/binding.gyp)
in the "external" condition of the binding.gyp
now everything is working fine :-)
I am wondering if this rpath= linker flag should not be committed to binding.gyp. I don't see a reason why people would like to link against their own version of sqlite3 at compile time with the --sqlite flag and not link with this version also at runtime.
currently my node-sqlite3 install process is :
npm install --build-from-source --sqlite=/path/to/custom/sqlite3 sqlite3
edit binding.gyp internal to add the new line above
npm rebuild --build-from-source --sqlite=/path/to/custom/sqlite3 sqlite3
if you could add the rpath 'libraries+' line in the binding.gyp, the install process could be streamlined to just
npm install --build-from-source --sqlite=/path/to/custom/sqlite3 sqlite3
Tell me if you think you could accept this modification to binding.gyp ("external" branch).
ps: congrats on the binding implementation ! modern c++ as advertised :-)