Monday, December 17, 2018

Hangs when using trylock reader writer lock functions


The pthreads reader writer locks have a couple of problems that can lead to application hangs. The trylock functions can cause other threads to hang indefinitely in the rdlock or wrlock functions even after the lock is no longer held.  If these hanging threads hold other locks, the application can deadlock and grind to a halt.  This bug was reported in glibc bug 23844 and has existed since glibc 2.25 was released.  The 2.25 version includes a new reader writer lock implementation which replaces large critical sections with compare and exchange atomic instructions.  The code paths for an uncontended lock should be very fast.  Unfortunately, a couple of bugs that can hang the application need to be fixed.

The trywrlock function is a non-blocking function that tries to grab a write lock on a reader writer lock.  Unfortunately, this function is missing logic that the wrlock function has when the phase of the reader writer lock transitions from read phase to write phase.  This missing logic is intended to synchronize the state of the lock with other reader threads so that when the write lock is released, blocked reader threads are awakened.  Since the logic is missing, the reader threads are not awakened.

The tryrdlock function is a non-blocking function that tries to grab a read lock on a reader writer lock.  Unfortunately, this function is missing logic that the rdlock function has when the phase of the reader writer lock transitions from write phase to read phase.  This missing logic awakens reader threads that may be waiting for the read phase.  It just so happened that the thread executing tryrdlock got there first.  Since the logic is missing, the reader threads are not awakened.

There are patches to the trywrlock and tryrdlock functions in the glibc bug report that fix these bugs.  Hopefully, these patches will be included in a new glibc release soon.

The MySQL server uses reader writer locks for various purposes.  I wonder if it is affected by these reader writer lock bugs.




4 comments:

  1. Peau Jeune

    Site officiel (Magasinez maintenant) :- https://www.dietarycafe.com/peau-jeune-avis-fr/

    Visitez maintenant plus d'informations:-

    https://www.completefoods.co/diy/recipes/peau-jeune-2
    https://sites.google.com/site/dietarycafe/peau-jeune
    https://medium.com/@dietarycafe/peau-jeune-avis-d89c0665a2ee
    https://dietarycafe.blogspot.com/2019/11/peau-jeune.html
    http://thedietarycafe.over-blog.com/peau-jeune

    Vous pourriez utiliser quelque chose comme Glowing Skin. Vous n'avez qu'à savoir quelles sont vos compétences. Comment dois-je détailler anti-vieillissement - Anti Anti Wrinkle Cream pour vous? Tu es l'un des plus chanceux. C'était un dessin animé comme dans Anti Vieillissement - Anti Wrinkle Cream, il faut utiliser le bon Anti Vieillissement - Anti Wrinkle Cream.

    ReplyDelete
  2. If you need to ​​​write a memo paper​, place your order on this writing service.

    ReplyDelete
  3. They must have good hygiene so I am more radical than most big babies when it draws a parallel to Keto Advanced Fat Burner. In this respect, the Keto Advanced Fat Burner that we want to manage is Keto Advanced Fat Burner that is hard earned. I feel justified in believing that touching on Keto Advanced Fat Burner. I am seeing several stupid arguments as that concerns Keto Advanced Fat Burner. Rest assured,



    Keto Advanced Fat Burner

    ReplyDelete
  4. For sure, so how do you get Keto Advanced Fat Burner at a decrepit price? Throwing more hard earned cash after it is probably not a good hypothesis. Keto Advanced Fat Burner is not something that companions should be left to do for themselves like that.


    Keto Advanced
    Keto Advanced Weight Loss

    ReplyDelete