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

MemoryRegion::is_disjoint_from can overflow on u64 addition #320

Closed
Sword-Smith opened this issue Aug 16, 2024 · 0 comments
Closed

MemoryRegion::is_disjoint_from can overflow on u64 addition #320

Sword-Smith opened this issue Aug 16, 2024 · 0 comments
Labels
🪳 bug Something is not working

Comments

@Sword-Smith
Copy link
Collaborator

Sword-Smith commented Aug 16, 2024

The following test panics, because of the value of the free_mem_page_ptr field.

    #[test]
    fn problem {
        let mem_layout = DynamicTasmConstraintEvaluationMemoryLayout {
            free_mem_page_ptr: BFieldElement::new(BFieldElement::MAX),
            challenges_ptr: BFieldElement::new(1 << 63),
        };
        mem_layout.is_integral();
    }

The problem arises because the free_mem_page_ptr region is assumed to have a size of MEM_PAGE_SIZE = $2^{32}$. And $-1 + 2^{32} = 2^{64} - 2^{32} + 2^{32} = 0\ mod\ 2^{64}$, which is an overflow.

The overflowing addition happens here.

@Sword-Smith Sword-Smith added the 🪳 bug Something is not working label Aug 16, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🪳 bug Something is not working
Projects
None yet
Development

No branches or pull requests

1 participant