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

Suppress compiler warning on potential buffer overflow #935

Open
wants to merge 3 commits into
base: dev
Choose a base branch
from

Conversation

doctorlai-msrc
Copy link

@doctorlai-msrc doctorlai-msrc commented Aug 31, 2024

The compiler gives the warning at (this issue):

error: '__atomic_load_8' writing 8 bytes into a region of size 0 overflows the destination [-Werror=stringop-overflow=]

In file included from /janus/3p/mimalloc/include/mimalloc/internal.h:17,
                 from /janus/3p/mimalloc/src/heap.c:9:
In function 'mi_heap_page_is_valid',
    inlined from 'mi_heap_page_collect' at /janus/3p/mimalloc/src/heap.c:95:3:
/janus/3p/mimalloc/src/heap.c:62:22: error: '__atomic_load_8' writing 8 bytes into a region of size 0 overflows the destination [-Werror=stringop-overflow=]
   62 |   mi_assert_internal(segment->thread_id == heap->thread_id);
      |                      ^~~~~~~

It is detecting a potential buffer overflow when accessing the thread_id in the segment structure. The warning suggests that the compiler believes the thread_id is being accessed in a way that could lead to reading or writing beyond the allocated memory of the structure.

This PR suppress this warning as I believe the code is safe (the false positive)

@doctorlai-msrc doctorlai-msrc marked this pull request as ready for review August 31, 2024 20:01
@doctorlai-msrc doctorlai-msrc changed the title Fix potential buffer overflow warning Suppress compiler warning on potential buffer overflow Aug 31, 2024
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

Successfully merging this pull request may close these issues.

1 participant