hideaki-t / sqlite-fts-python

A Python binding of SQLite Full Text Search Tokenizer
MIT License
45 stars 11 forks source link

segv if a python interpreter doesn't have separate _sqlite3 #37

Open hideaki-t opened 7 months ago

hideaki-t commented 7 months ago

python interpreters fetched from python-build-standalone (by rye) crash 100%. it occurs for all versions I tested locally 3.9, 3.10, 3.11, 3.12 on an Arch Linux VM x86-64.

it also happens on Debian aarch64.

hideaki-t commented 7 months ago

always this line. FTS3 works fine.

  File "/home/hideaki/sqlite-fts-python/sqlitefts/fts5.py", line 156 in fts5_api_from_db
hideaki-t commented 7 months ago

windows version interpreters don't seem to be affected. also Arch Linux's python package (3.11.7-1) is okay too.

hideaki-t commented 7 months ago

this is due to statically linked _sqlite3.so in libpython3.*.so, thus __file__ attribute doesn't exist for _sqlite3. it fallbacks to libsqlite3.so then hits the SEGV. so it's a similar issue to #19 and #30.

sqlite3 is also linked into libpython, so dlopen won't work, because APIs used by this package are local symbol; unable to resolve those symbols.

$ nm ~/.rye/py/cpython\@3.12.1/install/lib/libpython3.12.so.1.0  | grep sqlite3_prepare_v2
0000000000b06f80 t sqlite3_prepare_v2