Skip to content

Check table imports against the supplied table's current limits - #550

Merged
kateinoigakukun merged 3 commits into
mainfrom
maxd/table-import-limits
Dec 5, 2026
Merged

kateinoigakukun merged 3 commits into
mainfrom
maxd/table-import-limits

Conversation

@MaxDesiatov

Copy link
Copy Markdown
Member

A table import accepted a supplied table below the declared minimum or with a looser maximum. Table and memory imports now share Limits.satisfies over the supplied entity's current type, and their errors name that type as actual. The spec-test runner passed assert_trap and assert_unlinkable when the module they expect to fail instantiated without error. Now both expectedly report as failed. The runner's host table64 export is now i64-indexed.

A table import accepted a supplied table below the declared minimum or with a looser maximum. Table and memory imports now share `Limits.satisfies` over the supplied entity's current type, and their errors name that type as `actual`. The spec-test runner passed `assert_trap` and `assert_unlinkable` when the module they expect to fail instantiated without error. Now both expectedly report as failed. The runner's host `table64` export is now i64-indexed.
@MaxDesiatov
MaxDesiatov force-pushed the maxd/table-import-limits branch from d2a19e7 to 764252b Compare December 4, 2026 16:13
`currentType` copied the declared type and overwrote its minimum with the
current size, which produced a type that neither the module nor the entity
declares, and `Limits.satisfies` then compared two `Limits` values that mean
different things.

Match with `limitsMatch`, which takes the demanded minimum and maximum, the
supplied entity's current size and its declared maximum. The index type and
the shared flag are compared at the call sites. The mismatch error still
reports the size the entity has now, built only on the failure path.
@kateinoigakukun
kateinoigakukun force-pushed the maxd/table-import-limits branch from fb32a6c to fef9b43 Compare December 5, 2026 04:59
@kateinoigakukun
kateinoigakukun enabled stacked auto-merge (squash) December 5, 2026 05:15
@kateinoigakukun
kateinoigakukun merged commit f17e880 into main Dec 5, 2026
15 of 20 checks passed
@kateinoigakukun
kateinoigakukun deleted the maxd/table-import-limits branch December 5, 2026 05:36
kateinoigakukun added a commit that referenced this pull request Dec 5, 2026
`memoryImportRefusesDifferentSharedFlag(supplied: true)` creates a shared memory, which needs mprotect-based bounds checking. That is unavailable under AddressSanitizer and on Windows, so `Memory(...)` throws before the import is checked. This broke `build-macos` (which runs `swift test --sanitize address`) and `build-windows` after #550.

The `supplied: true` case now runs only where `SpectestTests.sharedMemorySupported`. The `supplied: false` case, which imports a non-shared memory as shared, runs everywhere.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants