Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

bug: OS addition results in Int(0) for dest_ptr #424

Open
notlesh opened this issue Nov 5, 2024 · 0 comments
Open

bug: OS addition results in Int(0) for dest_ptr #424

notlesh opened this issue Nov 5, 2024 · 0 comments
Labels
bug Something isn't working

Comments

@notlesh
Copy link
Collaborator

notlesh commented Nov 5, 2024

We previously created a workaround for an issue where dest_ptr is not a relocatable in #371. This PR works around the issue, but doesn’t understand or fix it.

I spent some more time looking at this recently and wanted to summarize my findings. I was not able to reproduce the issue with a standalone cairo0 program. It seems the compiler is good about preventing pointers-to-structs from being cast as integers in the way we see in the original issue.

The issue seems to happen when we add 1 to the pointer, that is (from segment_arena.cairo):

  • let dest_ptr = infos[0].end + 1; ⇒ dest_ptr is Int(0)
  • let end_ptr = infos[0].end;
    let dest_ptr = end_ptr + 1;
    ⇒ end_ptr is a proper relocatable, dest_ptr is Int(0)
  • While experimenting with cairo0 code, I found that a ptr to a struct gets a special Python treatment; specifically, it is represented as an instance of starkware.cairo.lang.vm.vm_consts.VmConstsReference. This may impact the way hints are executed (for example, it may have special treatment for the + operator).
  • There are no relocation rules present at the time this code is executed.

Given the above, I think there is something unexpected happening during the addition.

@notlesh notlesh added the bug Something isn't working label Nov 5, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant