verifier: preserve resource obligations across CFG handoff
This commit is contained in:
1 parent
0e98638bc6
commit
09fbf8a5bc
34 files changed
+1267
-67
No files matched your search
@@ -506,6 +506,8 @@ Depends on `ownership`.
|
||||
|
||||
**Function-bound.** A `scope` or `task<T>` may be passed between blocks of the function that created it (as a block argument) and used by `task.*`. It may not be a function parameter, a return type, an aggregate member, or stored in heap or region memory; those uses belong to the reserved feature `task_transfer` (`E0006` reason `feature_not_declared`). Keeping handles in their function keeps loans intraprocedural (invariant 6).
|
||||
|
||||
Passing block arguments MUST preserve each task's creating scope and outstanding loans; the creating spawn remains diagnostic context (§34). Arguments are transferred simultaneously: renaming a scope also renames its association with tasks that remain live. Verification covers every incoming edge, including backedges; SSA renaming does not discharge an obligation.
|
||||
|
||||
**Result type.** `task<T>` requires `T: Send`, and `T` must not transitively contain a borrow, a `scope` or a `task<…>`. A spawned function returning a borrow (for example one derived from a lent argument) belongs to the reserved feature `task_borrow_returns` (`E0006`): after `join`, whether the loan ends or continues as the returned borrow is deliberately left undefined in format 0.
|
||||
|
||||
### 33.2 Instructions
|
||||
@@ -696,6 +698,8 @@ cancelled(%t2: task<u64>):
|
||||
|
||||
`shield` is linear, function-bound (§33.1) and `Local`. The stack of live shields is part of the verifier state and MUST be identical on every edge into a block (`E3002`); every shield is ended before `ret` (`E3002`). Shield depth is dynamic per task, so a function called inside a shield runs shielded.
|
||||
|
||||
Block-argument transfer preserves shield order.
|
||||
|
||||
```text
|
||||
%a = task.shield.begin
|
||||
%b = task.shield.begin
|
||||
@@ -811,6 +815,8 @@ Decision record: RFC 0012. Depends on `cancellation`. `RwLock` is deferred (rese
|
||||
|
||||
No fairness is promised (§32). There is no poisoning and no implicit unlock; an unconsumed guard is `E3002`.
|
||||
|
||||
Block-argument transfer preserves the association between a live guard and the mutex borrow through which it was obtained.
|
||||
|
||||
`mutex<T>` is always linear and never copyable, whatever `T` is; `mutex.take` is the only way to dismantle it. It requires that no borrow of the mutex is live. A guard is a child of the `ref<mutex<T>>` it was locked through (ending that borrow while the guard lives is `E2102`), and a task waiting in `mutex.lock` holds such a borrow, so no guard and no waiter can exist at `mutex.take`. Afterwards the mutex is dead, by the ordinary rules for a dismantled linear value (as after `own.take`): a further use is `E3001` and a further consumption `E2002`.
|
||||
|
||||
## 41. The critical-section rule
|
||||
|
||||
Reference in new issue
Block a user