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

Invalid allocation when using the System implicit #1850

Open
matzayonc opened this issue Oct 11, 2024 · 2 comments
Open

Invalid allocation when using the System implicit #1850

matzayonc opened this issue Oct 11, 2024 · 2 comments
Labels
bug Something isn't working

Comments

@matzayonc
Copy link

Describe the bug
A clear and concise description of what the bug is.
When I include core::internal::require_implicit::<System>(); into any program, the cairo1run binary crashes with the error below.

Error: VirtualMachine(Hint((0, Memory(InconsistentMemory((Relocatable { segment_index: 1, offset: 7 }, RelocatableValue(Relocatable { segment_index: 13, offset: 0 }), RelocatableValue(Relocatable { segment_index: 14, offset: 0 })))))))

To Reproduce
Steps to reproduce the behavior:

  1. Create the program below
fn main(input: Array<felt252>) -> Array<felt252> {
    core::internal::require_implicit::<System>();
    input
}
  1. Run it with cairo1run
    cargo run -r --manifest-path ../cairo-vm/cairo1-run/Cargo.toml ../lib.cairo --args "[0 0]" --layout all_cairo --print_output --proof_mode

  2. See error

Expected behavior
The output of the program instead of an error.

What version/commit are you on?
For example: v0.6.0, e762069, etc.
Current main, rev=3fb0344ce038b3a68cae897c403d1f561cfe8da7

Additional context

Related to: https://t.me/lambdaworks/9122

I am working on a custom version of cairo-vm, that would be able to run contracts and I hit a blocker.

I managed to add a custom plugin, and gas management is also handled, and working fine. The issue I had was with the memory, which fails. If I try to access the program's arguments and there is a core::internal::require_implicit::<System>(); anywhere in the program, I get the error above.

Potentially unexpected change in the AP pointer.
I traced the problem back to failed allocation hint here:


The issue is present on the main branch as well, so not attaching a repository.

I think I narrowed down the place where the allocation hint is triggered.
hint AllocSegment {} into {dst: system}; here:

hint AllocSegment {} into {dst: system};
ap += 1;

@matzayonc matzayonc added the bug Something isn't working label Oct 11, 2024
@PabloVillaplana
Copy link

Hey @matzayonc Can I take this one?

@matzayonc
Copy link
Author

Hey @matzayonc Can I take this one?

That would be very helpful, it's still a blocker for me, thanks!

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

2 participants