tursodatabase / tursodatabase/libsql

Dereference of opaque `sqlite3_context` type.

Open
#1,501 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
C
Stars
17.2k
Forks
531
Avg merge
1h 12m
Merged PRs (30d)
1

Description

sqlite3_context is a opaque type when used out of vdbe.c and should not be dereferenced, since it's definition is incomplete at comptime.

https://github.com/tursodatabase/libsql/blob/be6a38fbd4d620b3d0f0d4c8962c9d5bdc339796/libsql-sqlite3/src/alter.c#L1868-L1870

This goes under the radar because of the "amalgamation" aproach to build the source. (Yet another drawback https://github.com/tursodatabase/libsql/issues/1028#issuecomment-2185625330). The solution is to #include "vdbeInt.h", but this is very smelly. If the type should be known by the whole source, better add it to sqlite3Int.h.

The func.c includes vdbeInt.h already.

https://github.com/tursodatabase/libsql/blob/af8239736b2d67c705728be45ba2f8ebe3ae6c1a/libsql-sqlite3/src/func.c#L23

Here is some docs:
https://github.com/tursodatabase/libsql/blob/be6a38fbd4d620b3d0f0d4c8962c9d5bdc339796/libsql-sqlite3/src/vdbeInt.h#L374-L398

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Inspect the dereference in libsql-sqlite3/src/alter.c at lines 1868-1870, then compare the declarations in sqlite3Int.h and vdbeInt.h with the existing include in libsql-sqlite3/src/func.c. Check how a non-amalgamated build exposes sqlite3_context and determine which header should own its definition. Done means the source compiles without relying on amalgamation while preserving the intended opaque-type boundary.

Written by the indexing model from the issue text.

Assessment

Tech stack
c, sqlite
Domain
databases
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.