Public bug reported:
Ubuntu release: Ubuntu 24.04 LTS (Noble)
Source package: sqlite3 / libsqlite3-0
Summary
The Ubuntu-packaged libsqlite3.so.0 crashes with a segmentation fault
while preparing a valid SQL statement containing nested parenthesized
JOINs.
The same SQL executes successfully with the official upstream SQLite
3.45.1 amalgamation compiled locally on the same machine, indicating
that the problem is specific to Ubuntu's packaged SQLite rather than
upstream SQLite 3.45.1.
Package versions
$ dpkg-query -W -f='${Package} ${Version} ${Architecture}\n'
libsqlite3-0 python3
libsqlite3-0 3.45.1-1ubuntu2.7 amd64
python3 3.12.3-0ubuntu2.1 amd64
The issue was also reproduced with the original Ubuntu 24.04 package:
libsqlite3-0 3.45.1-1ubuntu2
Runtime version
import sqlite3
print(sqlite3.sqlite_version)
print(sqlite3.connect(":memory:").execute(
"SELECT sqlite_source_id()"
).fetchone()[0])
Output:
3.45.1
2024-01-30 16:01:20
e876e51a0ed5c5b3126f52e532044363a014bc594cfefa87ffb5b82257ccalt1
Minimal reproducer
python3 - <<'PY'
import sqlite3
db = sqlite3.connect(":memory:")
db.executescript("""
CREATE TABLE t1(a);
CREATE TABLE t2(a);
CREATE TABLE t3(a);
CREATE TABLE t4(a);
""")
print(db.execute("""
SELECT t1.a
FROM t1
JOIN (
t2 JOIN (
t3 JOIN t4 ON t4.a=t3.a
) ON t3.a=t2.a
) ON t2.a=t1.a
""").fetchall())
print("NO CRASH")
PY
echo "exit=$?"
Expected result
The query is valid SQL and should execute successfully.
Since all tables are empty, the expected output is:
[]
NO CRASH
exit=0
Actual result
The Python interpreter terminates with SIGSEGV:
Segmentation fault
exit=139
Additional observation
Replacing the query with:
EXPLAIN
SELECT t1.a
FROM t1
JOIN (
t2 JOIN (
t3 JOIN t4 ON t4.a=t3.a
) ON t3.a=t2.a
) ON t2.a=t1.a;
also results in a segmentation fault.
This suggests the crash occurs during statement preparation (parsing,
name resolution, or query planning) rather than during query execution.
Upstream comparison
To verify whether this is an upstream SQLite issue, I downloaded the
official SQLite 3.45.1 amalgamation from:
[https://www.sqlite.org/2024/sqlite-
amalgamation-3450100.zip](https://www.sqlite.org/2024/sqlite-
amalgamation-3450100.zip)
and built it locally on the same Ubuntu 24.04 machine using:
gcc -O2 -DSQLITE_THREADSAFE=1 -DSQLITE_ENABLE_EXPLAIN_COMMENTS shell.c
sqlite3.c -ldl -lpthread -lm -o sqlite3-upstream-3.45.1
The resulting executable is statically linked with the upstream SQLite
source and does not load Ubuntu's libsqlite3.so.0.
Running the same SQL using this upstream build completes successfully
with exit status 0 and does not crash.
This reproducer does not require any external database, user data,
concurrency, extensions, or application-specific code. It consistently
reproduces the crash using only an in-memory database and four empty
tables. I believe this demonstrates a reproducible defect in Ubuntu's
packaged SQLite library that is not present in the official upstream
SQLite 3.45.1 source.
ProblemType: Bug
DistroRelease: Ubuntu 24.04
Package: libsqlite3-0 3.45.1-1ubuntu2.7
ProcVersionSignature:
Uname: Linux 6.8.12-33-pve x86_64
ApportVersion: 2.28.2-0ubuntu0.1
Architecture: amd64
CasperMD5CheckResult: unknown
Date: Thu Jul 23 13:28:22 2026
Dependencies:
gcc-14-base 14.2.0-4ubuntu2~24.04.1
libc6 2.39-0ubuntu8.7
libgcc-s1 14.2.0-4ubuntu2~24.04.1
libidn2-0 2.3.7-2build1.1
libunistring5 1.1-2build1.1
SourcePackage: sqlite3
UpgradeStatus: No upgrade log present (probably fresh install)
** Affects: sqlite3 (Ubuntu)
Importance: Undecided
Status: New
** Tags: amd64 apport-bug noble
--
You received this bug notification because you are a member of Ubuntu
Bugs, which is subscribed to Ubuntu.
https://bugs.launchpad.net/bugs/2161638
Title:
libsqlite3-0 3.45.1-1ubuntu2.7 segfaults preparing valid nested JOIN
query (upstream SQLite 3.45.1 does not)
To manage notifications about this bug go to:
https://bugs.launchpad.net/ubuntu/+source/sqlite3/+bug/2161638/+subscriptions
--
ubuntu-bugs mailing list
[email protected]
https://lists.ubuntu.com/mailman/listinfo/ubuntu-bugs