mirror of
https://github.com/varun-r-mallya/Python-BPF.git
synced 2026-12-06 18:08:36 +00:00
Core: Pass helpers the pointer a local holds, not its slot's address
A local bound to a map lookup holds a pointer, and get_or_create_ptr_from_arg handed a helper the address of that local's stack slot instead. So count.update(k, prev) stored the kernel address of the map value, not the value, and after prev = prev + 1 it stored the address of the temporary. The verifier accepts both when loading as root, so nothing failed: the failing_tests/vmlinux/named_arg.py example has been passing all along while storing the wrong thing. The slot is now loaded when it holds a pointer. named_arg.py moves to passing_tests, and both it and a new map_update_from_lookup.py are pinned by IR assertions. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
This commit is contained in:
@ -67,6 +67,11 @@ def get_or_create_ptr_from_arg(
|
||||
else:
|
||||
# Stack space is already allocated
|
||||
ptr = get_var_ptr_from_name(arg.id, local_sym_tab)
|
||||
if symbol is not None and isinstance(symbol.ir_type, ir.PointerType):
|
||||
# The slot holds a pointer (a map lookup result, or a local
|
||||
# rebound to point at a temporary): the helper wants that
|
||||
# pointer, not the address of the slot it is kept in.
|
||||
ptr = builder.load(ptr)
|
||||
elif isinstance(arg, ast.Constant) and isinstance(arg.value, int):
|
||||
int_width = 64 # Default to i64
|
||||
if expected_type and isinstance(expected_type, ir.IntType):
|
||||
|
||||
Reference in New Issue
Block a user