You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@brpc.apache.org by GitBox <gi...@apache.org> on 2020/09/08 04:27:49 UTC

[GitHub] [incubator-brpc] Ailusa0106 opened a new issue #1230: wait_for_butex在加入队列前验证butex锁变量的值可能还是老值而导致进入等待队列而产生永不唤醒

Ailusa0106 opened a new issue #1230:
URL: https://github.com/apache/incubator-brpc/issues/1230


   **Describe the bug (描述bug)**
   thread1 butex_wake释放锁变量移除thread1出队列结束,wait_for_butex获取的锁变量值可能还是老值(未刷新)而导致进入wait而永不唤醒
   
   **To Reproduce (复现方法)**
   使用
   
   **Expected behavior (期望行为)**
   能正常运行
   
   **Versions (各种版本)**
   OS:
   Compiler:
   brpc:
   protobuf:
   
   **Additional context/screenshots (更多上下文/截图)**
   ![image](https://user-images.githubusercontent.com/70932122/92432814-de656c80-f1cd-11ea-943c-fe44d8d72179.png)
   
   


----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@brpc.apache.org
For additional commands, e-mail: dev-help@brpc.apache.org


[GitHub] [incubator-brpc] Ailusa0106 commented on issue #1230: wait_for_butex在加入队列前验证butex锁变量的值可能还是老值而导致进入等待队列而产生永不唤醒

Posted by GitBox <gi...@apache.org>.
Ailusa0106 commented on issue #1230:
URL: https://github.com/apache/incubator-brpc/issues/1230#issuecomment-688672893


   > > 值
   > 
   > butex/futex 的语义本身就不保证能看到最新值, 这里保证的都是"使用姿势正确"的前提下. 1) waiter 能看到最新的只。 or 2) waiter会被waker通过 *utex_wake() 唤醒.
   
   嗯,多谢回复,主要是针对这个正确的姿势,拿bthread_mutex_unlock举例,假设两个thread,thread1解锁,此时锁变量的值去和0交换,交换之后利用butex_wake唤醒队列(但是此时队列为空),如果thread2 wait_for_butex这个时候看不到最新值就会lock(append进入队列),但是已经没有thread能唤醒它了。


----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@brpc.apache.org
For additional commands, e-mail: dev-help@brpc.apache.org


[GitHub] [incubator-brpc] Ailusa0106 commented on issue #1230: wait_for_butex在加入队列前验证butex锁变量的值可能还是老值而导致进入等待队列而产生永不唤醒

Posted by GitBox <gi...@apache.org>.
Ailusa0106 commented on issue #1230:
URL: https://github.com/apache/incubator-brpc/issues/1230#issuecomment-688693930


   > > 嗯,多谢回复,主要是针对这个正确的姿势,拿bthread_mutex_unlock举例,假设两个thread,thread1解锁,此时锁变量的值去和0交换,交换之后利用butex_wake唤醒队列(但是此时队列为空),如果thread2 wait_for_butex这个时候看不到最新值就会lock(append进入队列),但是已经没有thread能唤醒它了。
   > 
   > 这是不可能的,wait一端获取waiter_lock后必然能看到最新值。这类多线程问题的先验知识比较多,解释起来也比较困难,你可能得自己去学习一下了。
   
   好的,多谢戈大神回复


----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@brpc.apache.org
For additional commands, e-mail: dev-help@brpc.apache.org


[GitHub] [incubator-brpc] jamesge commented on issue #1230: wait_for_butex在加入队列前验证butex锁变量的值可能还是老值而导致进入等待队列而产生永不唤醒

Posted by GitBox <gi...@apache.org>.
jamesge commented on issue #1230:
URL: https://github.com/apache/incubator-brpc/issues/1230#issuecomment-688691129


   > 嗯,多谢回复,主要是针对这个正确的姿势,拿bthread_mutex_unlock举例,假设两个thread,thread1解锁,此时锁变量的值去和0交换,交换之后利用butex_wake唤醒队列(但是此时队列为空),如果thread2 wait_for_butex这个时候看不到最新值就会lock(append进入队列),但是已经没有thread能唤醒它了。
   
   这是不可能的,wait一端获取waiter_lock后必然能看到最新值。这类多线程问题的先验知识比较多,解释起来也比较困难,你可能得自己去学习一下了。


----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@brpc.apache.org
For additional commands, e-mail: dev-help@brpc.apache.org


[GitHub] [incubator-brpc] jamesge closed issue #1230: wait_for_butex在加入队列前验证butex锁变量的值可能还是老值而导致进入等待队列而产生永不唤醒

Posted by GitBox <gi...@apache.org>.
jamesge closed issue #1230:
URL: https://github.com/apache/incubator-brpc/issues/1230


   


----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@brpc.apache.org
For additional commands, e-mail: dev-help@brpc.apache.org


[GitHub] [incubator-brpc] chenzhangyi commented on issue #1230: wait_for_butex在加入队列前验证butex锁变量的值可能还是老值而导致进入等待队列而产生永不唤醒

Posted by GitBox <gi...@apache.org>.
chenzhangyi commented on issue #1230:
URL: https://github.com/apache/incubator-brpc/issues/1230#issuecomment-688640358


   请问有复现的case吗? 还是通过看代码得到的结论


----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@brpc.apache.org
For additional commands, e-mail: dev-help@brpc.apache.org


[GitHub] [incubator-brpc] Ailusa0106 commented on issue #1230: wait_for_butex在加入队列前验证butex锁变量的值可能还是老值而导致进入等待队列而产生永不唤醒

Posted by GitBox <gi...@apache.org>.
Ailusa0106 commented on issue #1230:
URL: https://github.com/apache/incubator-brpc/issues/1230#issuecomment-688651366


   > 请问有复现的case吗? 还是通过看代码得到的结论
   
   你好,看代码的结论,感觉这块无法完全保证获取的是最新值


----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@brpc.apache.org
For additional commands, e-mail: dev-help@brpc.apache.org


[GitHub] [incubator-brpc] chenzhangyi commented on issue #1230: wait_for_butex在加入队列前验证butex锁变量的值可能还是老值而导致进入等待队列而产生永不唤醒

Posted by GitBox <gi...@apache.org>.
chenzhangyi commented on issue #1230:
URL: https://github.com/apache/incubator-brpc/issues/1230#issuecomment-688665802


   > 值
   
   butex/futex 的语义本身就不保证能看到最新值, 这里保证的都是"使用姿势正确"的前提下. 1) waiter 能看到最新的只。 or 2) waiter会被waker通过 *utex_wake() 唤醒.


----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@brpc.apache.org
For additional commands, e-mail: dev-help@brpc.apache.org