Skip to content

Fix incrementing before mmap success check#3515

Closed
devarajabc wants to merge 0 commit intoptitSeb:mainfrom
devarajabc:0215
Closed

Fix incrementing before mmap success check#3515
devarajabc wants to merge 0 commit intoptitSeb:mainfrom
devarajabc:0215

Conversation

@devarajabc
Copy link
Contributor

@devarajabc devarajabc commented Feb 15, 2026

Move list->size increment after the mmap failure check.
After mmap fails and returns 0, list->size has already been permanently incremented.
On the next call to AllocDynarecMap, this loop iterates up to the new list->size,
hitting the uninitialized list->chunks[i].

@ptitSeb
Copy link
Owner

ptitSeb commented Feb 15, 2026

I understand the issue, but this was done that way to help with mutli-threaded access and avoid having competition when initializing the new list. Not sure this fix will handle heavy multi-threading well.

@ptitSeb
Copy link
Owner

ptitSeb commented Feb 15, 2026

It would be safer to do the int i = list->size++; to after the potential point of failure, and just use list->size when trying to get the map size as it's readonly and not a critical information anyway.

@devarajabc
Copy link
Contributor Author

devarajabc commented Feb 15, 2026

I see, you are right. The mmap failure path is nearly impossible to hit in practice. It's not worth it

@devarajabc devarajabc closed this Feb 15, 2026
@devarajabc
Copy link
Contributor Author

Maybe I can add a comment for it.

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.

2 participants