runtimeverification / runtimeverification/mir-semantics

Decode constant call arguments before storing them in callee locals

Open
#1,070 2 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Python
Stars
52
Forks
5
PR merge metrics
No merged PRs in 30d

Description

#setArgsFromStack currently handles constant call arguments by forwarding the raw operandConstant(...) term into #setLocalValue:

rule <k> #setArgFromStack(IDX, operandConstant(_) #as CONSTOPERAND)
      =>
         #setLocalValue(place(local(IDX), .ProjectionElems), CONSTOPERAND)
      ...
     </k>

This is unsafe if the #setLocalValue write rule can fire before the constant operand is evaluated/decoded to a Value. In that case, the callee local may be written as typedValue(operandConstant(...), TY, MUT).

That violates the local-storage invariant documented in rt/value.md and rt/data.md: locals are TypedLocals, and a TypedValue must carry a Value payload. Later rules that rely on getValue(...), isValue(...), or projection traversal may then get stuck or continue with an invalid local payload.

The fix should keep the scope limited to call-argument setup:

  • add a regression test for passing a constant argument into a callee and reading it there;
  • ensure the constant argument is evaluated/decoded to a Value before it is stored in callee <locals>;
  • prevent raw Operand terms such as operandConstant(...) from appearing inside typedValue(...);
  • preserve the existing operandCopy / operandMove handling for caller locals, reference-height adjustment, and moved locals.

It is fine for an unevaluated construct to enter locals only through an explicit thunk(...), since that is itself a Value; the issue is storing a raw Operand as the TypedValue payload.

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with #setArgsFromStack/#setArgFromStack and #setLocalValue, then read rt/value.md and rt/data.md for the local-storage invariant. Add a regression test that passes a constant argument into a callee and reads it there. Done means constant arguments are decoded to Values before storage, while operandCopy/operandMove, reference-height adjustment, moved locals, and explicit thunks retain their existing behavior.

Written by the indexing model from the issue text.

Assessment

Domain
compilers
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Quiet
Clarity
Mostly clear
Newbie friendliness
58/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.