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

Memory overflow bug #1283

Closed
Juan-M-V opened this issue Jun 26, 2023 · 0 comments · Fixed by #1285
Closed

Memory overflow bug #1283

Juan-M-V opened this issue Jun 26, 2023 · 0 comments · Fixed by #1285
Assignees
Labels
bug Something isn't working

Comments

@Juan-M-V
Copy link
Contributor

Juan-M-V commented Jun 26, 2023

Describe the bug
VM panic

To Reproduce
A compiled cairo program that uses default_dict_new can be altered to trigger a panic in the VM:
thread 'main' panicked at 'capacity overflow', library/alloc/src/raw_vec.rs:525:5
To reproduce, first compile this cairo program:

from starkware.cairo.common.default_dict import default_dict_new
from starkware.cairo.common.dict_access import DictAccess

func main() {
    alloc_locals;
    let (local my_dict: DictAccess*) = default_dict_new(1);
    return ();
}

Then modify the json, specifically the -7 (in felt format, it'll be the largest hex string) to any big positive number (again, felt notation), an easy option is to delete everything after the 1. After that run the program and this will make the VM panic
An alternative is to delete all the data and call the instruction:

 {
  "inst": "0x1104800180018000",
  "opcode": "Call",
  "ap_update": "Add2",
  "pc_update": "JumpRel",
  "res_logic": "Op1",
  "op1_addr": "Imm",
  "op0_reg": "AP",
  "dst_reg": "AP",
  "off0": 0,
  "off1": 1,
  "off2": 1,
  "Imm": "big positive number",
}

and making sure the data has at least 5 entries :

"data": [
    "0x1",
    "0x1",
    "0x1",
    "0x1104800180018000",
    "0x80000000000001"
]

Expected behavior
An error should be raised

What version/commit are you on?
For example: v0.7.0

@Juan-M-V Juan-M-V added the bug Something isn't working label Jun 26, 2023
@Juan-M-V Juan-M-V closed this as not planned Won't fix, can't repro, duplicate, stale Jun 26, 2023
@Juan-M-V Juan-M-V reopened this Jun 26, 2023
@pefontana pefontana moved this to Todo in Starknet Jun 27, 2023
@pefontana pefontana moved this from Todo to In Progress in Starknet Jun 27, 2023
@MegaRedHand MegaRedHand moved this from In Progress to In Review in Starknet Jun 27, 2023
@github-project-automation github-project-automation bot moved this from In Review to Done in Starknet Jun 29, 2023
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
Status: Done
Development

Successfully merging a pull request may close this issue.

2 participants