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

VM crashes with big hint PCs #1338

Closed
Juan-M-V opened this issue Jul 18, 2023 · 2 comments · Fixed by #1340
Closed

VM crashes with big hint PCs #1338

Juan-M-V opened this issue Jul 18, 2023 · 2 comments · Fixed by #1340
Labels
bug Something isn't working

Comments

@Juan-M-V
Copy link
Contributor

Descrption
Giving the VM a compiled program with a big hint PC location results in two kinds of panics: attempt to add with overflow if the number is usize::MAX and capacity overflow if the number is big enough.

To Reproduce
Create a program that has something similar to this in the hints section:

{
    "attributes": [],
    "builtins": [],
    "compiler_version": "0.11.0",
    "data": [],
    "debug_info": {
    	"instruction_locations": {}
    },
    "hints": {
        "18446744073709551615": [
            {
                "accessible_scopes": [],
                "code": "",
                "flow_tracking_data": {
                    "ap_tracking": {
                        "group": 0,
                        "offset": 0
                    },
                    "reference_ids": {}
                }
            }
        ]
    },
    "identifiers": {
        "__main__.main": {}
    },
    "main_scope": "",
    "prime": "0x800000000000011000000000000000000000000000000000000000000000001",
    "reference_manager": {
        "references": []
    }
}

Expected behavior
The VM should throw an Error instead of panicing

Used version
v0.8.2

Additional context
This bug was found when trying to execute a Program created by manually initializing the fields, without the use of the parser

Program {
    shared_program_data: SharedProgramData {
        data: vec![],
        hints: vec![],
        hints_ranges: vec![
            Some(
                (
                    usize::MAX,
                    NonZeroUsize::new(1_usize).unwrap(),
                ),
            ),
        ],
        main: Some(0),
        start: None,
        end: None,
        error_message_attributes: vec![],
        instruction_locations: None,
        identifiers: HashMap::new(),
        reference_manager: vec![],
    }.into(),
    constants: HashMap::new(),
    builtins: vec![],
}
@Juan-M-V Juan-M-V added the bug Something isn't working label Jul 18, 2023
@MegaRedHand
Copy link
Contributor

Problem continues when manually building the Program struct

@MegaRedHand MegaRedHand reopened this Jul 21, 2023
@MegaRedHand
Copy link
Contributor

Talking with @Juan-M-V, this "bug" cannot be caused by a user, as the Program struct cannot be built directly. With the checks added in #1340, neither can this be built from a parsed program.

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

Successfully merging a pull request may close this issue.

2 participants