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

test/contention: release size store first #184

Merged
merged 1 commit into from
May 13, 2020

Conversation

nwf
Copy link
Collaborator

@nwf nwf commented May 12, 2020

It is important, in test_tasks_f, that the store of the size to the
allocated block be made visible to other processors before the store of
the pointer itself. Otherwise, other cores are justified in reading
junk.

This manifests on PowerPC as tripping the "Deallocating with incorrect
size supplied" assertion in alloc.h:/check_size because the value read
from the allocated block may not be a size but rather an internal queue
pointer, which is implausibly large, as sizes go.

@@ -86,7 +86,7 @@ void test_tasks_f(size_t id)

*res = size;
size_t* out =
contention[n % swapsize].exchange(res, std::memory_order_relaxed);
contention[n % swapsize].exchange(res, std::memory_order_release);
Copy link
Member

Choose a reason for hiding this comment

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

I think you are right, but shouldn't it be std::memory_order_acq_rel as this performs as a read as well, that needs to induce the happens-before edge?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Yea, I think you're right. I think I thought the data dependencies in this thread would be sufficient, but they're not.

It is important, in test_tasks_f, that the store of the size to the
allocated block be made visible to other processors before the store of
the pointer itself.  Otherwise, other cores are justified in reading
junk.

This manifests on PowerPC as tripping the "Deallocating with incorrect
size supplied" assertion in alloc.h:/check_size because the value read
from the allocated block may not be a size but rather an internal queue
pointer, which is implausibly large, as sizes go.
@nwf nwf force-pushed the contention-release branch from 3f610ae to 446a729 Compare May 13, 2020 13:06
@mjp41 mjp41 merged commit ce47fde into microsoft:master May 13, 2020
@nwf nwf deleted the contention-release branch June 30, 2021 18:36
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