Skip site navigation (1)Skip section navigation (2)
Date:      Tue, 23 Aug 2016 21:20:48 +0000
From:      bugzilla-noreply@freebsd.org
To:        freebsd-threads@FreeBSD.org
Subject:   [Bug 211947] bconsole won't die sitting on do_rw_wrlock
Message-ID:  <bug-211947-16-x1OOjrBGaI@https.bugs.freebsd.org/bugzilla/>
In-Reply-To: <bug-211947-16@https.bugs.freebsd.org/bugzilla/>
References:  <bug-211947-16@https.bugs.freebsd.org/bugzilla/>

next in thread | previous in thread | raw e-mail | index | archive | help
https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=3D211947

--- Comment #2 from longwitz@incore.de ---
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 =3D 0;
static pthread_mutex_t global_mutex =3D 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,0x7fffdfffde=
f8)
 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 syst=
em
call
 83194 100732 thrtest  1.043625 CALL  getpid
 83194 101055 thrtest  1.043640 PSIG  SIG 32 caught handler=3D0x80082d080
mask=3D0x0 code=3DSI_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=20
_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=20
_umtx_op(0x800a42880,UMTX_OP_RW_WRLOCK,0,0,0)
 83194 101055 thrtest  1.043743 CALL=20
_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=20
_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=20
_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=20
_umtx_op(0x800a42880,UMTX_OP_RW_UNLOCK,0,0,0)
 83194 101055 thrtest  1.043785 CALL=20
_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=20
_umtx_op(0x800a42880,UMTX_OP_RW_WRLOCK,0,0,0)
 83194 101055 thrtest  1.043800 CALL=20
_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=20
_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 30163=
3.

--=20
You are receiving this mail because:
You are the assignee for the bug.=



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?bug-211947-16-x1OOjrBGaI>