[solved] percentile module, as extension segmentation fault on load
(1.1) By das784 on 2024-11-04 20:59:33 edited from 1.0 [source]
I've been trying to get the percentile module to work as an extension. The pre-4.7 version works, but everything after 4.7 causes a segmentation fault on .load
.
To duplicate, I downloaded: sqlite.org/2024/sqlite-autoconf-3470000.tar.gz
build using:
gcc shell.c sqlite3.c -lpthread -ldl -lm -o sqlite3
Build percentile.c
gcc -g -fPIC -shared percentile.c -o percentile.so
try to load
$ sqlite3
> .load /path/to/percentile.so
Segmentation fault (core dumped)
I've tried both the latest percentile.c,
sqlite.org/src/file?name=ext/misc/percentile.c
and also the one from
sqlite.org/2024/sqlite-src-3470000.zip,
at ext/misc/percentile.c
The 3.46 version of percentile.c does build and load.
The 3.47 version also works fine with no segmentation fault, if I compile it into the shell, using:
gcc -DSQLITE_STATIC_PERCENTILE=1 \
shell.c sqlite3.c -lpthread -ldl -lm -o sqlite3
The extension-related code seems to match the definitions in the load extension documentation, so I'm not sure why it doesn't work as an extension but does work when compiled into the sqlite3 binary?
This is on arch linux (6.11.4-arch2-1).
(2) By anonymous on 2024-11-04 19:46:14 in reply to 1.0 [link] [source]
ext/misc/percentile.c
fails at static-or-extension distinction.
#if defined(SQLITE3_H) || defined(SQLITE_STATIC_PERCENTILE) (void)pApi; /* Unused parameter */ #else SQLITE_EXTENSION_INIT2(pApi); #endif
Since sqlite3ext.h
includes sqlite3.h
, SQLITE3_H
is always defined here.
(3) By Richard Hipp (drh) on 2024-11-04 20:17:55 in reply to 1.0 [link] [source]
Please try again with the latest check-in from a few minutes ago. https://sqlite.org/src/finfo/ext/misc/percentile.c
(4) By das784 on 2024-11-04 20:59:13 in reply to 3 [link] [source]
Thank you, that worked!
(5) By ddevienne on 2024-11-04 21:49:25 in reply to 3 [link] [source]
FWIW, the issue I reported in https://sqlite.org/forum/forumpost/463890920c, specific to Windows, seems unaddressed.
(6) By Aask (AAsk1902) on 2024-11-04 21:55:02 in reply to 3 [link] [source]
Recompiled without issues but the problem I reported remains .
(7) By Pawel Salawa (googie) on 2024-12-01 13:30:31 in reply to 3 [link] [source]
This fix is not included in 3.47.1 source code package.
(8) By Stephan Beal (stephan) on 2024-12-01 16:24:09 in reply to 7 [link] [source]
This fix is not included in 3.47.1 source code package.
That change was made only to the trunk and did not make it into the 3.47 branch. It is now in that branch but we don't yet know whether there will be 3.47.x patch releases. If you need that fix in 3.47 you'll need to patch it manually or download and build branch-3.47, as documented at https://sqlite.org/src.