Skip to content

CI: build with SQLITE3MC_SECURE_MEMORY=ON using clang - #320

Merged
utelle merged 1 commit into
utelle:mainfrom
akdilsiz:ci/secure-memory-clang
Nov 27, 2026
Merged

utelle merged 1 commit into
utelle:mainfrom
akdilsiz:ci/secure-memory-clang

Conversation

@akdilsiz

Copy link
Copy Markdown
Contributor

Description

Adds a CI job that configures the CMake build with
-DSQLITE3MC_SECURE_MEMORY=ON and builds it with clang on Linux and macOS.

The secure memory code (src/memory_secure.c) is compiled only when
SQLITE3MC_SECURE_MEMORY=1 is defined. No existing CI job defines it, so this
code is never compiled by CI, with any compiler. The CMake build is used
because the autotools build passes -std=c99, which selects a different
branch of the MC_ATOMIC_* macros in src/hwcheck.c than the default C
standard of clang (C11 <stdatomic.h>).

Problem Statement

A configuration that is shipped (CMake option SQLITE3MC_SECURE_MEMORY,
premake5.lua, the conan recipe) is not built by CI. A real regression of this
kind existed in v2.7.1: src/memory_secure.c declared
static volatile int mcSecureMemoryFlag and accessed it with
MC_ATOMIC_LOAD/STORE, which expand to atomic_load_explicit /
atomic_store_explicit in the C11 branch. Clang rejects this for a
non-_Atomic object; gcc accepts it. It is fixed on main (the flag is a
mcAtomicUInt now), but nothing in CI would catch a similar problem again.

  • Reproducible test case included
  • Compiler / sanitizer evidence provided
  • Verified incorrect behavior shown in code
  • Reference to external technical source (if applicable)

Verification

Local, offline builds with CMake 4.5.1 and Apple Clang 17.0.0
(clang-1700.6.3.2), CC=clang:

Source Configure Result
tag v2.7.1, -DSQLITE3MC_SECURE_MEMORY=ON ok build fails
tag v2.7.1, default options ok build succeeds
main + this change, -DSQLITE3MC_SECURE_MEMORY=ON ok build succeeds, no warnings in memory_secure.c

First errors of the failing build:

src/memory_secure.c:192:31: error: address argument to atomic operation must be a pointer to _Atomic type ('volatile int *' invalid)
src/memory_secure.c:198:5: error: address argument to atomic operation must be a pointer to _Atomic type ('volatile int *' invalid)

Commands (per source tree, build directory outside the tree):

CC=clang cmake -S <src> -B <build> -DSQLITE3MC_SECURE_MEMORY=ON
cmake --build <build>

So the failure is specific to the secure memory configuration, which no
existing job builds, and current main passes the new job.

  • Locally reproducible
  • Unit test added/updated
  • Static analysis / sanitizer output
  • Other (please specify): CI configuration only; the new job itself runs
    in this PR's checks.

Type of Change

  • Bug Fix (requires verifiable evidence)
  • Feature / Enhancement (new functionality)
  • Refactor (no behavior change)
  • Documentation
  • Other (please describe): CI configuration only (new job in
    .github/workflows/ci4sqlite3mc.yml); no library code is changed.

Problem / Motivation

The job is a build-only check: the failure mode is a compile error, and the
job copies the structure of the existing android_build job (checkout, CMake
configure, CMake build; no new actions, no new dependencies). CC=clang is set
as in host_unix.

Checklist

  • I have independently verified the issue
  • I am not submitting unverified or speculative changes
  • I understand that AI-assisted changes must be reviewed by a human before submission

No existing job defines SQLITE3MC_SECURE_MEMORY, so src/memory_secure.c is never compiled by CI. Add a CMake build job with clang on Linux and macOS that enables it; the CMake build keeps the default C standard of clang, which selects the C11 atomics branch.
@utelle

utelle commented Nov 27, 2026

Copy link
Copy Markdown
Owner

Thanks for provoding this additional CI job step.

@utelle
utelle merged commit 6490c53 into utelle:main Nov 27, 2026
17 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants