[Bug 211947] bconsole won't die sitting on do_rw_wrlock

[email protected]
Newsgroups gmane.os.freebsd.devel.threading
Message-ID <[email protected]/bugzilla/>
https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=211947

--- Comment #2 from [email protected] ---
In the meantime I have extracted the pthread relevant parts of the program
bconsole and can give a working program thrtest.c that demonstrates the
problem:

#include <pthread.h>
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>

static int global_ct = 0;
static pthread_mutex_t global_mutex = PTHREAD_MUTEX_INITIALIZER;
static pthread_t work_thread;

void register_thread() {
   pthread_mutex_lock(&global_mutex);
   ++global_ct;
   pthread_mutex_unlock(&global_mutex);
}

void unregister_thread() {
   pthread_mutex_lock(&global_mutex);
   --global_ct;
   pthread_mutex_unlock(&global_mutex);
}

void clean_handler(void *a) {
   unregister_thread();
}

void *work_start(void *x) {
   register_thread();
   pthread_cleanup_push(clean_handler, NULL);

   while (sleep(30))
      getpid();
   pthread_cleanup_pop(1);
   exit(global_ct);
}

void cleanup_main() {
   pthread_cancel(work_thread);
   unregister_thread();
   pthread_mutex_lock(&global_mutex);
   getpid();
   pthread_mutex_unlock(&global_mutex);
}

int main(int argc, char *argv[]) {
   register_thread();
   pthread_create(&work_thread, NULL, work_start, NULL);
   getpid();
   sleep(1);
   cleanup_main();
   exit(global_ct);
}

The relevant parts of ktrace output starting with sleep(1) from main():

 83194 101055 thrtest  0.001482 CALL  nanosleep(0x7fffdfffdf08,0x7fffdfffdef8)
 83194 100732 thrtest  1.043574 RET   nanosleep 0
 83194 100732 thrtest  1.043602 CALL  thr_kill(0x18abf,SIG 32)
 83194 100732 thrtest  1.043617 RET   thr_kill 0
 83194 101055 thrtest  1.043624 RET   nanosleep -1 errno 4 Interrupted system
call
 83194 100732 thrtest  1.043625 CALL  getpid
 83194 101055 thrtest  1.043640 PSIG  SIG 32 caught handler=0x80082d080
mask=0x0 code=SI_LWP
 83194 100732 thrtest  1.043657 RET   getpid 83194/0x144fa
 83194 101055 thrtest  1.043676 CALL  thr_wake(0x18abf)
 83194 101055 thrtest  1.043686 RET   thr_wake 0
 83194 101055 thrtest  1.043691 CALL  thr_wake(0x18abf)
 83194 101055 thrtest  1.043696 RET   thr_wake 0
 83194 101055 thrtest  1.043701 CALL  sigreturn(0x7fffdfffda70)
 83194 101055 thrtest  1.043708 RET   sigreturn JUSTRETURN
 83194 101055 thrtest  1.043716 CALL 
_umtx_op(0x800a42880,UMTX_OP_RW_RDLOCK,0,0,0)
 83194 101055 thrtest  1.043723 RET   _umtx_op 0
 83194 100732 thrtest  1.043725 CALL 
_umtx_op(0x800a42880,UMTX_OP_RW_WRLOCK,0,0,0)
 83194 101055 thrtest  1.043743 CALL 
_umtx_op(0x800a42880,UMTX_OP_RW_UNLOCK,0,0,0)
 83194 101055 thrtest  1.043757 RET   _umtx_op 0
 83194 101055 thrtest  1.043762 CALL 
_umtx_op(0x800a42880,UMTX_OP_RW_UNLOCK,0,0,0)
 83194 101055 thrtest  1.043767 RET   _umtx_op 0
 83194 101055 thrtest  1.043771 CALL 
_umtx_op(0x800a42880,UMTX_OP_RW_RDLOCK,0,0,0)
 83194 100732 thrtest  1.043771 RET   _umtx_op 0
 83194 101055 thrtest  1.043779 RET   _umtx_op -1 errno 4 Interrupted system
call
 83194 100732 thrtest  1.043781 CALL 
_umtx_op(0x800a42880,UMTX_OP_RW_UNLOCK,0,0,0)
 83194 101055 thrtest  1.043785 CALL 
_umtx_op(0x800a42880,UMTX_OP_RW_RDLOCK,0,0,0)
 83194 100732 thrtest  1.043789 RET   _umtx_op 0
 83194 101055 thrtest  1.043792 RET   _umtx_op 0
 83194 100732 thrtest  1.043797 CALL 
_umtx_op(0x800a42880,UMTX_OP_RW_WRLOCK,0,0,0)
 83194 101055 thrtest  1.043800 CALL 
_umtx_op(0x800a42880,UMTX_OP_RW_UNLOCK,0,0,0)
 83194 101055 thrtest  1.043805 RET   _umtx_op 0
 83194 101055 thrtest  1.043811 CALL 
_umtx_op(0x800a42880,UMTX_OP_RW_UNLOCK,0,0,0)
 83194 101055 thrtest  1.043813 RET   _umtx_op 0
 83194 101055 thrtest  1.043816 CALL  thr_exit(0x801406800)

Now the process 83194 hangs and procstat gives

  PID    TID COMM             TDNAME           KSTACK
83194 100732 thrtest          -                mi_switch+0xe1
sleepq_catch_signals+0xab sleepq_wait_sig+0xf _sleep+0x27d umtxq_sleep+0x125
do_rw_wrlock+0x5af __umtx_op_rw_wrlock+0x47 amd64_syscall+0x40f
Xfast_syscall+0xfb

  PID    TID COMM             TDNAME           CPU  PRI STATE   WCHAN
83194 100732 thrtest          -                  1  122 sleep   uwrlck

Please can somebody verify this bug in FreeBSD 10.3 STABLE, my rev is 301633.

-- 
You are receiving this mail because:
You are the assignee for the bug.
_______________________________________________
[email protected] mailing list
https://lists.freebsd.org/mailman/listinfo/freebsd-threads
To unsubscribe, send any mail to "[email protected]"
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.