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

Make heap small chunk size setting logic more precise/correct #4527

Merged
merged 2 commits into from
Oct 15, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .release-notes/4527.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
## Fix actor heap chunk size tracking bug that could cause a segfault

The [0.55.1](https://github.com/ponylang/ponyc/releases/tag/0.55.1) release included some internal actor heap implementation optimizations. Unfortunately, there was a small bug that could potentially cause a segfault due to not properly clearing some bits before setting them for some heap chunks. This change corrects that oversight to ensure the relevant bits are properly cleared before being set to ensure they final result can never be incorrect.
2 changes: 1 addition & 1 deletion src/libponyrt/mem/heap.c
Original file line number Diff line number Diff line change
Expand Up @@ -212,7 +212,7 @@ static void set_small_chunk_size(small_chunk_t* chunk, size_t size)

// left shift size to get bits in the right spot for OR'ing into `chunk->m`
size = size << SMALL_CHUNK_SIZECLASS_SHIFT;
((chunk_t*)chunk)->m = (char*)((uintptr_t)((chunk_t*)chunk)->m | (size & SMALL_CHUNK_SIZECLASS_BITMASK));
((chunk_t*)chunk)->m = (char*)(((uintptr_t)((chunk_t*)chunk)->m & ~SMALL_CHUNK_SIZECLASS_BITMASK) | (size & SMALL_CHUNK_SIZECLASS_BITMASK));
}

static bool get_chunk_needs_clearing(chunk_t* chunk)
Expand Down
Loading