Skip to content

fix: correct TaggedPtr::as_ptr#45

Merged
nekevss merged 1 commit intoboa-dev:mainfrom
shruti2522:as_ptr
Mar 11, 2026
Merged

fix: correct TaggedPtr::as_ptr#45
nekevss merged 1 commit intoboa-dev:mainfrom
shruti2522:as_ptr

Conversation

@shruti2522
Copy link
Contributor

the TaggedPtr::as_ptr method was previously using XOR to remove the tag bit , this incorrectly corrupted untagged pointers by tagging them. Fixed it to use addr & !MASK to safely clear the tag bit without modifying untagged addresses.

run_drop_check never caught this bug because the function iterates backwards and early returns false immediately on encountering an untagged pointer.

I guess this should be fixed to ensure the correctness of as_ptr() function

Added test as_ptr_clears_not_flips_tag_bit() to verify the failure, the test failed without the fix

before the fix:
image

Copy link
Member

@nekevss nekevss left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oops 😅

@nekevss nekevss merged commit f37d70e into boa-dev:main Mar 11, 2026
4 checks passed
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