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

fix(bitfield): fix raw_mask shifting twice #262

Merged
merged 1 commit into from
Jul 24, 2022
Merged

Conversation

hawkw
Copy link
Owner

@hawkw hawkw commented Jul 24, 2022

There's currently a bug in the raw_mask method on
mycelium-bitfield's packing spec types. raw_mask returns self.mask
shifted over by self.shift, with the intention of returning the actual
mask used by the packing spec. But...the self.mask field is already
shifted to the correct bit position, so shifting it in the raw_mask
method results in the mask being shifted over twice as many bits as it's
supposed to be.

This caused some very weird behavior in the maitake task state
management code, where attempting to toggle a bit using its raw_mask
would accidentally clobber low bits of the ref count, resulting in a
ref-count underflow in some cases.

There's currently a bug in the `raw_mask` method on
`mycelium-bitfield`'s packing spec types. `raw_mask` returns `self.mask`
shifted over by `self.shift`, with the intention of returning the actual
mask used by the packing spec. But...the `self.mask` field is already
shifted to the correct bit position, so shifting it in the `raw_mask`
method results in the mask being shifted over twice as many bits as it's
supposed to be.

This caused some *very* weird behavior in the `maitake` task state
management code, where attempting to toggle a bit using its `raw_mask`
would accidentally clobber low bits of the ref count, resulting in a
ref-count underflow in some cases.
@hawkw hawkw enabled auto-merge (squash) July 24, 2022 20:17
@hawkw hawkw merged commit 8c34ef9 into main Jul 24, 2022
@hawkw hawkw deleted the eliza/fix-raw-mask branch July 24, 2022 20:24
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.

None yet

1 participant