-
Notifications
You must be signed in to change notification settings - Fork 13.5k
[DWARFLinkerParallel] Change more cases of compare_exchange_weak to compare_exchange_strong #138692
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
Conversation
…ompare_exchange_strong This is a follow-up to 07bc54b; this seems to perhaps fix occasional crashes in dsymutil on Windows on aarch64. While these are used in loops, which could be tolerant to concurrent accesses, the overall logic seems to assume that they don't have spurious failures; I've observed one case in a debugger, where LastGroup == nullptr within the loop in ArrayList::add(). The remaining uses of compare_exchange_weak() in DWARFLinkerCompileUnit.h also seem very suspicious; if there would be a true concurrent write, leading to compare_exchange_weak() returning false, it seems like we would get stuck in an endless loop - but changing them to compare_exchange_strong() wouldn't make any difference with respect to that.
Can you have a look at these cases? (I haven't run into issues with them, but the code looks like it could lock up.) |
yes, you are right those places look incorrect. Thank you for pointing to this. Instead of
there should be something like
and loop should be added to:
Would you prefer me to do these changes or would you prefer to do these changes youself? |
Yes, that looks correct to me. As you're more familiar with the overall intent here (I'm just trying to debug things that show up when running |
Ok, Will do that way(open PR and do changes) Thank you again for finding this! |
…ompare_exchange_strong (llvm#138692) This is a follow-up to 07bc54b; this fixes more occasional crashes in dsymutil on Windows on aarch64.
My answer was too hurry. This code looks OK:
There should not be endless loop here. if there would be a true concurrent write, leading to compare_exchange_weak() returning false, then InputData would be updated with current value of "Flags". Then it would - either match on next iteration and loop will finish, either(in case new concurrent write) it would be updated again. So, after this MR was integrated, it looks like no more other issues inside dwarflinker parallel with usages of compare_exchange_weak. |
Oh, indeed - you're right, I forgot that it updates the |
This is a follow-up to 07bc54b; this seems to perhaps fix occasional crashes in dsymutil on Windows on aarch64.
While these are used in loops, which could be tolerant to concurrent accesses, the overall logic seems to assume that they don't have spurious failures; I've observed one case in a debugger, where LastGroup == nullptr within the loop in ArrayList::add().
The remaining uses of compare_exchange_weak() in
DWARFLinkerCompileUnit.h also seem very suspicious; if there would be a true concurrent write, leading to compare_exchange_weak() returning false, it seems like we would get stuck in an endless loop - but changing them to compare_exchange_strong() wouldn't make any difference with respect to that.