You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When casting a felt to a felt pointer in Cairo0 (such as cast(0, felt*)), cairo-vm writes an Integer to memory instead of a Relocatable.
The OS code does this in a number of cases like: this. This particular case is later used with add_relocation_rule() which always fails because it will only accept a Relocatable.
The following example Cairo code demonstrates the problem:
from starkware.cairo.common.alloc import alloc
func main() {
alloc_locals;
let ptr_from_alloc: felt* = alloc();
let ptr_from_cast_0: felt* = cast(0, felt*);
%{ breakpoint() %}
ret;
}
Reproducing this issue can be done by using the cairo0_run binary in this PR. Something like this:
Save the cairo snippet above as test_cast.cairo.
Compile it with cairo-compile, e.g. cairo-compile test_cast.cairo --output test_cast_compiled.json
Run the SNOS cairo0_run binary with the output, e.g. cargo run -p cairo0_run -- --input test_cast_compiled.json
The breakpoint hint will print ids_data, showing the values of the variables
Expected behavior
Based on the OS code in cairo-lang I believe the expectation is that cast in this case should return a Relocatable, but I'm not entirely clear on this.
Describe the bug
When casting a felt to a felt pointer in Cairo0 (such as
cast(0, felt*)
),cairo-vm
writes an Integer to memory instead of a Relocatable.The OS code does this in a number of cases like: this. This particular case is later used with
add_relocation_rule()
which always fails because it will only accept aRelocatable
.The following example Cairo code demonstrates the problem:
This results in:
To Reproduce
Reproducing this issue can be done by using the
cairo0_run
binary in this PR. Something like this:test_cast.cairo
.cairo-compile
, e.g.cairo-compile test_cast.cairo --output test_cast_compiled.json
cairo0_run
binary with the output, e.g.cargo run -p cairo0_run -- --input test_cast_compiled.json
ids_data
, showing the values of the variablesExpected behavior
Based on the OS code in cairo-lang I believe the expectation is that
cast
in this case should return aRelocatable
, but I'm not entirely clear on this.What version/commit are you on?
58363ad8065ed891e3b14a8191b707677c7c7cb5b9d10030822506786d8d8108
(roughlyv1.0.1
)Additional context
We have created a workaround in SNOS here.
The text was updated successfully, but these errors were encountered: