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

Cirtical error: calculating of aligned address #3

Open
iaoing opened this issue Jan 23, 2023 · 0 comments
Open

Cirtical error: calculating of aligned address #3

iaoing opened this issue Jan 23, 2023 · 0 comments

Comments

@iaoing
Copy link

iaoing commented Jan 23, 2023

Issue:

In Python, the result of int/int is the float type and the size is as same as the float in C/C++. However, the int type in Python is unbounded. Thus, conversion from floating point to integer may round or truncate as in C.

Affected code:

  1. Calculating of cache line aligned address:

    def get_cacheline_address(address):
    return int(address / CACHELINE_BYTES) * CACHELINE_BYTES

  2. calculating of atomic-size aligned address:

    address_atomic_write_low = int(address/ATOMIC_WRITE_BYTES) * \
    ATOMIC_WRITE_BYTES

If the address starts with 0xf, the result is incorrect after the calculation.

Fixes:

aligned_addr = address // ALIGNMENT_NUM * ALIGNMENT_NUM
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant