Skip to content

Require iyi 0.21.0 and iyi-db 0.5.0, and mark the raw-memory module - #1

Merged
sdogruyol merged 1 commit into
masterfrom
iyi-0.21
Nov 10, 2026
Merged

sdogruyol merged 1 commit into
masterfrom
iyi-0.21

Conversation

@sdogruyol

Copy link
Copy Markdown
Contributor

What

iyi 0.21.0 refuses an operation on raw memory in a module that doesn't say it handles some (SPEC.md III.13). A module says so with one @[Unsafe("why")] above its module header, a mark 0.20.x refuses. 0.21.0 also adds safe calls for the common cases: String#byte_at, Bytes.of and String.new(Array(UInt8)). iyi-db v0.4.0 is refused by 0.21.0 too; v0.5.0 carries its marks.

On 0.21.0, master is refused in sqlite/core (the libsqlite3 binding) and sqlite/dates (text.to_unsafe), so every test fails to build.

This PR:

  • Marks sqlite/core, the module that calls libsqlite3: "calls libsqlite3 through its C binding with the connection and statement handles it answers, passing text and blobs by pointer and copying the text and blobs it answers out of the library's memory".
  • Safe calls: sqlite/dates parses a time's text with byte_at instead of indexing to_unsafe, so the compiler checks every index.
  • REGEXP_FN is @[UnsafeReach] instead of @[SafeReach]. 0.21.0 proves a SafeReach claim (SPEC.md III.4.4), and refused this one: handing the proc to sqlite3_create_function counts as a write it cannot place. UnsafeReach keeps the claim on trust, and is allowed in a module marked @[Unsafe].
  • pool_test's writers use spawn(unit: :same). 0.21.0 runs a plain spawn in parallel when its block captures only Share values (III.4.15), and a Database is Share, so the five writers ran at once and SQLite answered "database is locked" (no busy_timeout). crystal-sqlite3's fibers shared one thread, which unit: :same keeps.
  • Minimum iyi 0.21.0 in CI's IYI_VERSION and README Requirements, iyi.mod requiring github.com/iyilang/db v0.5.0 (iyi.sum from iyi get github.com/iyilang/db@v0.5.0), and a CHANGELOG Unreleased entry.

No spawn_parallel/spawn_serial/parallel:/serial: spellings were in the repository.

Tests (iyi 0.21.0 release binary, Linux x86_64)

The iyi-0.21.0-linux-x86_64.tar.gz from the v0.21.0 release, against the system's libsqlite3, CI's steps:

  • iyi test sqlite: 6 passed, 0 failed, three runs. Before the pool_test change it was 5 passed, 1 failed ("database is locked").
  • examples/memory.iyi builds and runs.
  • iyi fmt --check sqlite.iyi sqlite examples passes; iyi check of sqlite.iyi and the example prints nothing.

iyi 0.21.0 refuses an operation on raw memory in a module that is not
marked @[Unsafe("why")] above its module header (SPEC.md III.13), and
0.20.x refuses the mark. sqlite/core, which calls libsqlite3, is marked,
saying what it does with the memory. sqlite/dates reads a time's text
with byte_at instead, so the compiler checks it.

0.21.0 proves a @[SafeReach] claim instead of trusting it, and handing
REGEXP_FN to sqlite3_create_function is beyond the proof, so it is
@[UnsafeReach], taken on trust in a marked module (III.4.4).

A plain spawn whose block captures only Share values runs in parallel on
0.21.0 (III.4.15), so pool_test's five writers hit "database is locked"
with no busy_timeout; they stay in the test's unit with
spawn(unit: :same), as crystal-sqlite3's fibers shared one thread.

iyi-db 0.4.0 is refused by 0.21.0 too, so iyi.mod requires 0.5.0, the
release that carries its marks; iyi.sum is from
`iyi get github.com/iyilang/db@v0.5.0`.
@sdogruyol
sdogruyol merged commit 575dcf4 into master Nov 10, 2026
1 check passed
@sdogruyol
sdogruyol deleted the iyi-0.21 branch November 10, 2026 07:06
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.

1 participant