-
Notifications
You must be signed in to change notification settings - Fork 90
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
Changes wrt recent crashes of nodes #165
Conversation
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.
- I think it's better to split the openssl and socket changes to another PR.
- It seems the
_spin_yield_lock
was there to ensure consistency of multiple members in apromise_base
object, although not all members are protected at all times. This PR changed the behavior to mostly only try to protect individual members. Is it safe? std::atomic
is working on the threading layer but not the tasking layer, so it seems the new code will wait when unable to obtain a lock but will not yield to another task. A question is whether it will lead to deadlock or starvation. I guess the answer is no, because the lock would be being held by another thread and will be released fast enough, so won't matter if current task in current thread need to wait for a while.
_blocked_thread = &thread::current(); | ||
do | ||
assert( !blocked_thread || blocked_thread == &thread::current() ); | ||
while( !_blocked_thread.compare_exchange_weak( blocked_thread, &thread::current() ) ); |
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.
This looks suspicious, although the old behavior is kept. It guarantees that _blocked_thread
will be replaced by current thread, but in release build assert(...)
will be dropped, so _blocked_thread
could be replaced by another thread when it's already set.
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.
I made a brief attempt to improve it but didn't succeed, then decided to keep the old behaviour.
I'm pretty sure, yes. The only two places where the
No. Note that with a modern compiler and hardware |
2df4364
to
0407979
Compare
Done -> #166 |
@pmconrad for easier to test, please rebase to |
f4179b4
to
2cc32d7
Compare
Rebased |
Added a fix for zero-initialization of |
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.
The code in 020a37e itself looks fine. I didn't check whether there are other instances where Update: I've checked.std::array
is used though.
020a37e
to
ed479c8
Compare
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!
* added some safety for openssl type wrappers, just in case(moved to #166)