Fix fast lock on windows (reassignment oldval) #956
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
コミット 07ed42b (2023-10-28) で、Windows の fast lock (spin lock) が、
ScmAtomicVar を使うように変更されましたが、
このときにロックできなくなっていたため修正しました。
以下の test_0002_write で不具合を確認しました。
https://gist.github.com/Hamayama/fda48fd11d3583653edbbdd9d7d7e714
原因は、src/gauche/priv/atomicP.h で、
AO_compare_and_swap_full() が 3 パターン定義されていますが、
元々の libatomic_ops のもの以外は、
条件不成立時に oldval を現在の値で置き換えるという仕様があったためです。
この仕様のために、スピンの2周目で、条件が逆転していました。
<関連 Issue>