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

Use volatile to prevent the compiler from optimizing alias pointers #17

Merged
merged 2 commits into from
Oct 11, 2024

Conversation

jjyr
Copy link
Owner

@jjyr jjyr commented Oct 11, 2024

Fix #16

I suspect the compiler may have discarded line 44 due to optimizations, compiler ignoring the potential for pointer aliasing. I haven't confirmed from the disassembly, but this PR fixed the issue.

(*(*list).next).prev = p;
(*list).next = p;

I have also modified the code of buddy alloc to prevent potentially similiar errors.

After the fix, the performance even improved 8% ~ 10% on my macbook, it is because we removed a write_unaligned.

@jjyr jjyr merged commit 5eb39b2 into master Oct 11, 2024
2 checks passed
@jjyr jjyr deleted the volatile-read-write branch October 11, 2024 13:23
This was referenced Oct 15, 2024
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.

SIGSEV invalid memory reference when running tests
1 participant