Repository navigation
Conversation
Function.nodes, expressions and slithir_operations return their cached list without a copy. _explore_functions started from that list and extended it with `values +=`, so calling all_nodes(), all_expressions() or all_slithir_operations() appended every callee's nodes/expressions/operations to the function's own list. Copy it first. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_016xNEyu4v9TDCcVaJyaHkJy
|
Good catch — this is a real bug, and the copy is in the right place: the in-place extension happens in the One correction to the comment, though: Worth considering as a follow-up: make |
Summary
Function.all_nodes(),all_expressions()andall_slithir_operations()permanently append every callee's nodes, expressions and operations to the function's ownnodes,expressionsandslithir_operations.Root cause
_explore_functionsstarts withvalues = f_new_values(self)and then extends it withvalues += f_new_values(f)for each callee. Most getters return a copy (list(self._vars_read)and so on), butnodes,expressionsandslithir_operationsreturn the cached list itself. For those three,values +=extends the function's own cache in place.After any
all_*call on those three, code that iteratesfunction.slithir_operationsorfunction.nodessees the callees' operations as if they belonged to the function. A callee's parameters then appear as unknown values in the caller, which breaks data-dependency reasoning done per function.Fix
Copy the first list:
values = list(f_new_values(self)).Test
test_explore_does_not_mutate_own_lists(intests/unit/core/test_explore_functions.py, reusingtest_call_graph.sol) calls the threeall_*methods onchainA()and checks that its own lists are unchanged. It fails onmasterand passes with the fix.Other test runs:
tests/e2e/detectors: 384 passed.tests/unit: 6 Vyper tests fail in my environment (no Vyper installed), the same 6 with and without this change.🤖 Generated with Claude Code
https://claude.ai/code/session_016xNEyu4v9TDCcVaJyaHkJy