Translator: a constant blob past the module's bound is refused at its first read through memory

What: the refusal of a constant blob past memory::blob::MODULE_BYTES moves from the identity
domains' check after planning (select::identity_refusal) to lower::access::blob::use_blob, where
selection first meets a read of the blob. The refusal keeps its cause (IdentityCause::ConstantBlob),
its class (Unsupported{IdentityDomains}, not implemented) and its words ("constant data of N bytes
read through memory").

Why: the plan only holds a blob that use_blob recorded, so the check after planning tested what
selection already knew at the read; refusing there names the cause where the translator meets it,
with no second pass over the plan.

SEMANTICS_VERSION 2364 (renumbered at landing: 2363 went to arm 9): a kernel that reads such a blob
and meets another refusal later in selection now gets the blob's refusal, where it got the other
one before.

Public items: none change (IdentityCause::ConstantBlob stays, and api_signatures.tsv and
docs/REFUSALS.md do not move; refusal_surface.py --check passes). The refusal-pin test is
engine_identity's a_constant_blob_past_the_modules_bound_is_refused_naming_its_size (cause, class
and words on every committed profile); engine_arena's struct DAG case of 128 KiB of blob keeps its
refusal check. runtime-sources.sha256 is re-pinned.

Verified: see the jobs named below.
This commit is contained in:
Anees Iqbal committed 2026-12-03 12:06:16 -08:00
1 parent 6ba3572cbe
commit 6459eaa946
3 files changed
+13 -14

No files matched your search

+1 -1
View File
@@ -60,7 +60,7 @@ mod tests;
/// unchanged version, and its bless records the version. Independent of the crate's version and of
/// [`ARTIFACT_FORMAT_VERSION`]. The commit that bumps it says what changed; this comment keeps no
/// history.
pub const SEMANTICS_VERSION: u32 = 2363;
pub const SEMANTICS_VERSION: u32 = 2364;
/// The byte-layout version of encoded artifacts (`CompiledFunction::to_bytes` and the
/// [`PipelineArtifact`] encodings). Every encoded artifact carries it, and a decode under another
+12 -3
View File
@@ -17,10 +17,10 @@
use std::sync::Arc;
use crate::air::ir::{CastOp, Const, Inst, InstId, InstKind, Value, ValueId};
use crate::error::{AccessCause, Error};
use crate::error::{AccessCause, DiagName, Error, IdentityCause, Unsupported};
use crate::lower::emit::EmitCx;
use crate::lower::select::SelectCx;
use crate::memory::blob::{BlobUse, ModuleWords};
use crate::memory::blob::{BlobUse, ModuleWords, MODULE_BYTES};
use crate::memory::contain;
use crate::memory::leaf::{self, k32, Leaf, WordMem};
use crate::memory::plan::{ConstGlobalForm, MemoryPlan};
@@ -143,7 +143,9 @@ pub fn lowered_pointer(cx: &SelectCx<'_>, v: Value) -> Result<Option<DemoteTy>,
}
/// Record that the function reads the blob, its bytes shared with the memory plan's: the module's
/// words, with no descriptor.
/// words, with no descriptor. A blob past [`MODULE_BYTES`] is refused here, at the first read
/// through memory, naming its size (`Unsupported{IdentityDomains}`, not implemented: the module
/// holds no such blob's words).
pub fn use_blob(cx: &mut SelectCx<'_>) -> Result<(), Error> {
if cx.families.access.blob.is_some() {
return Ok(());
@@ -152,6 +154,13 @@ pub fn use_blob(cx: &mut SelectCx<'_>) -> Result<(), Error> {
Some(b) => Arc::clone(&b.bytes),
None => return Err(cx.invariant("a blob pointer without a blob")),
};
let len = bytes.len() as u64;
if len > MODULE_BYTES {
let form = format!("constant data of {len} bytes read through memory");
return Err(Unsupported::identity(IdentityCause::ConstantBlob)
.naming(DiagName::new(form))
.into());
}
cx.families.access.blob = Some(BlobUse { bytes });
Ok(())
}
-10
View File
@@ -1877,16 +1877,6 @@ fn identity_refusal(plan: &Plan) -> Option<(IdentityCause, String)> {
format!("state of a bound texture or sampler beyond its resource ID ({f:?})"),
));
}
// The module holds the blob's words (`memory::blob`) up to its bound.
if let Some(blob) = &plan.families.access.blob {
let bytes = blob.bytes.len() as u64;
if bytes > crate::memory::blob::MODULE_BYTES {
return Some((
IdentityCause::ConstantBlob,
format!("constant data of {bytes} bytes read through memory"),
));
}
}
// A bound kernel's storage views are set 0's storage buffers, one a view slot.
let bound = match views {
true => (plan.slots.iter().flatten())