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

Can overallocate #2

Open
alecmocatta opened this issue Nov 2, 2019 · 0 comments
Open

Can overallocate #2

alecmocatta opened this issue Nov 2, 2019 · 0 comments

Comments

@alecmocatta
Copy link
Owner

There's a race where one thread tries to overallocate: self.remaining.fetch_sub(size, Ordering::Acquire) >= size and correctly fails, but self.remaining has now wrapped, so another thread's attempt to overallocate (before the first thread has restored self.remaining) incorrectly succeeds.

I fixed this by switching self.remaining to isize and bounding allocations to isize::max_value() but had a brain blip and undid this.

Another possible solution is CAS to avoid decrementing self.remaining if it would wrap, or do a saturating decrement.

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