Skip to content

Improvements on rbtree_best_fit::check_sanity - #282

Open
MiguelCompany wants to merge 1 commit into
boostorg:developfrom
MiguelCompany:improve_check_sanity
Open

Improvements on rbtree_best_fit::check_sanity#282
MiguelCompany wants to merge 1 commit into
boostorg:developfrom
MiguelCompany:improve_check_sanity

Conversation

@MiguelCompany

@MiguelCompany MiguelCompany commented Aug 11, 2026

Copy link
Copy Markdown
Contributor

When checking the sanity of a shared memory segment, if the memory has been corrupted, the iterator might read outside the segment, producing a segfault.

This was found during the investigation of eProsima/Fast-DDS#6501

The proposed changes perform the quick check on the header before the loop.
Inside the loop, the check for the alignment is performed before accessing the data pointed to by the iterator, and the loop returns early whenever the accumulated free_memory value exceeds the limit.

This reduces the chance of the iterator jumping to an offset outside the segment.

Perform quick tests before iterating on the blocks.
Early exit from loop if block size is 0 or accumulated free memory exceeds maximum.

Signed-off-by: Miguel Company <miguelcompany@eprosima.com>
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