8000 Can overallocate · Issue #2 · alecmocatta/cap · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings
Can overallocate #2
Open
Open
@alecmocatta

Description

@alecmocatta

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      0