-
Notifications
You must be signed in to change notification settings - Fork 42
Fixed conditon on remove token reference. #39
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
josuttis
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
looks good. Thanks for catching this.
Nico
|
Hi Gaetano, Do you have any repro steps for the issue you tried to solve here? Because I think this introduced the issue #42 |
|
It was just pure satic code analysis, if the new version has an issue then
the same issue is in __remove_source_reference ( same condition )
…On Wed, Jun 16, 2021 at 10:39 AM Stephane Guy ***@***.***> wrote:
Hi Gaetano,
Do you have repro steps for the issue you tried to solve here? Because I
think this introduced the issue #42
<#42>
—
You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub
<#39 (comment)>, or
unsubscribe
<https://github.com/notifications/unsubscribe-auth/AAPIUZMFAGYUEJZF7I7R5BTTTBPM3ANCNFSM4ZSC3BGQ>
.
--
cpp-today.blogspot.com
|
|
Ok, the two methods need to have different conditions, this is not a bug. Here are the 3 methods that can delete the internal state: Lines 53 to 59 in 0fa8d39
and the ones that are correct Lines 65 to 71 in 0fa8d39
Lines 280 to 289 in 0fa8d39
And this is the values of the flags of the internal state: Lines 291 to 295 in 0fa8d39
The logic is always to delete the state when the new state is less or equal to |
|
Actually, you are correct. To summarize. The delete should happen when there are not more Sources or Tokens, so the reference counter reached 0. In this case 0 means that atomic contains only the locked or stopped bit on = 3. NewCounter <= 3 NewCounter = OldCounter - X OldCounter -x < __token_ref_increment tbh to avoid future confusion I would add: and then convert those conditions as: |
|
thanks a lot for your work.
I am currently very busy,
but I come back
Nico
Am 22. Juni 2021 22:25:58 MESZ schrieb Gaetano ***@***.***>:
Actually, you are correct.
To summarize. The delete should happen when there are not more Sources or Tokens, so the reference counter reached 0. In this case 0 means that atomic contains only the locked or stopped bit on = 3.
NewCounter <= 3
NewCounter < 4
NewCounter < __token_ref_increment
NewCounter = OldCounter - X
OldCounter -x < __token_ref_increment
OldCounter < __token_ref_increment + x
tbh to avoid future confusion I would add:
```
static constexpr std::uint64_t __emptyState = __stop_requested_flag + __locked_flag;
```
and then convert those conditions as:
```
auto __oldState =
__state_.fetch_sub(SOME_VALUE, std::memory_order_acq_rel);
if (__oldState <= (__emptyState + SOME_VALUE)) {
delete this;
}
```
--
You are receiving this because you modified the open/close state.
Reply to this email directly or view it on GitHub:
#39 (comment)
--
Nico Josuttis
(sent from my mobile phone)
|
Previous version was incorrectly not accounting for source reference counter but twice the token reference counter.