CESNET / libnetconf

C NETCONF library
Other
113 stars 83 forks source link

Deadlock when calling nc_session_close from multiple threads #202

Closed parkrish closed 8 years ago

parkrish commented 8 years ago

Hi ,

This is in continuation to the verification of issue #200 with latest master code.

I noticed that there is still deadlock between the notification thread and the send/receive thread because of two locks mut_ntf and mut_session. Notify thread holds mut_ntf and is waiting for mut_session lock. Can you please look into this issue ?

0 __lll_lock_wait () at ../nptl/sysdeps/unix/sysv/linux/x86_64/lowlevellock.S:135

1 0x00007f8322cfd4d4 in _L_lock_952 () from /lib/x86_64-linux-gnu/libpthread.so.0

2 0x00007f8322cfd336 in __GI___pthread_mutex_lock (mutex=0x269d078) at ../nptl/pthread_mutex_lock.c:114

3 0x00007f832312e53a in nc_session_close (session=0x269cff0, reason=NC_SESSION_TERM_DROPPED) at src/session.c:1225

4 0x00007f832312fcf6 in nc_session_receive (session=0x269cff0, timeout=0, msg=0x7f831c6e0e60) at src/session.c:2131

5 0x00007f832313074d in nc_session_recv_msg (session=0x269cff0, timeout=0, msg=0x7f831c6e0e60) at src/session.c:2363

6 0x00007f8323130eba in nc_session_recv_notif (session=0x269cff0, timeout=0, ntf=0x7f831c6e0ea0) at src/session.c:2542

7 0x00007f832313daf3 in ncntf_dispatch_receive (session=0x269cff0, process_ntf=0x7f8323ce189c ) at src/notifications.c:2681

Send /receive thread holding mut_session and waiting for mut_ntf

(gdb) bt

0 __lll_lock_wait () at ../nptl/sysdeps/unix/sysv/linux/x86_64/lowlevellock.S:135

1 0x00007f8322cfd4d4 in _L_lock_952 () from /lib/x86_64-linux-gnu/libpthread.so.0

2 0x00007f8322cfd336 in __GI___pthread_mutex_lock (mutex=0x269d118) at ../nptl/pthread_mutex_lock.c:114

3 0x00007f832312e2ba in ncntf_dispatch_stop (session=0x269cff0) at src/session.c:1194

4 0x00007f832312e582 in nc_session_close (session=0x269cff0, reason=NC_SESSION_TERM_DROPPED) at src/session.c:1234

5 0x00007f832312ec57 in nc_session_send (session=0x269cff0, msg=0x1ea8a20) at src/session.c:1524

6 0x00007f8323131f55 in nc_session_send_reply (session=0x269cff0, rpc=0x0, reply=0x25adf80) at src/session.c:2949

7 0x00007f83231306a8 in nc_session_receive (session=0x269cff0, timeout=100, msg=0x7fffd7866f58) at src/session.c:2345

8 0x00007f832313074d in nc_session_recv_msg (session=0x269cff0, timeout=100, msg=0x7fffd7866f58) at src/session.c:2363

9 0x00007f83231308bf in nc_session_recv_reply (session=0x269cff0, timeout=-1, reply=0x7fffd7867028) at src/session.c:2409

10 0x00007f832313228a in nc_session_send_recv (session=0x269cff0, rpc=0x2c10f40, reply=0x7fffd7867028) at src/session.c:3036

Regards, Parameswaran

Hi ,

Thanks for looking into the problem.I tested with latest master code. Unfortunately my problem is not solved yet.

There is still deadlock between the notification thread and the send/receive thread because of two locks mut_ntf and mut_session. Notify thread holds mut_ntf and is waiting for mut_session lock.

0 __lll_lock_wait () at ../nptl/sysdeps/unix/sysv/linux/x86_64/lowlevellock.S:135

1 0x00007f8322cfd4d4 in _L_lock_952 () from /lib/x86_64-linux-gnu/libpthread.so.0

2 0x00007f8322cfd336 in __GI___pthread_mutex_lock (mutex=0x269d078) at ../nptl/pthread_mutex_lock.c:114

3 0x00007f832312e53a in nc_session_close (session=0x269cff0, reason=NC_SESSION_TERM_DROPPED) at src/session.c:1225

4 0x00007f832312fcf6 in nc_session_receive (session=0x269cff0, timeout=0, msg=0x7f831c6e0e60) at src/session.c:2131

5 0x00007f832313074d in nc_session_recv_msg (session=0x269cff0, timeout=0, msg=0x7f831c6e0e60) at src/session.c:2363

6 0x00007f8323130eba in nc_session_recv_notif (session=0x269cff0, timeout=0, ntf=0x7f831c6e0ea0) at src/session.c:2542

7 0x00007f832313daf3 in ncntf_dispatch_receive (session=0x269cff0, process_ntf=0x7f8323ce189c ) at src/notifications.c:2681

Send /receive thread holding mut_session and waiting for mut_ntf

(gdb) bt

0 __lll_lock_wait () at ../nptl/sysdeps/unix/sysv/linux/x86_64/lowlevellock.S:135

1 0x00007f8322cfd4d4 in _L_lock_952 () from /lib/x86_64-linux-gnu/libpthread.so.0

2 0x00007f8322cfd336 in __GI___pthread_mutex_lock (mutex=0x269d118) at ../nptl/pthread_mutex_lock.c:114

3 0x00007f832312e2ba in ncntf_dispatch_stop (session=0x269cff0) at src/session.c:1194

4 0x00007f832312e582 in nc_session_close (session=0x269cff0, reason=NC_SESSION_TERM_DROPPED) at src/session.c:1234

5 0x00007f832312ec57 in nc_session_send (session=0x269cff0, msg=0x1ea8a20) at src/session.c:1524

6 0x00007f8323131f55 in nc_session_send_reply (session=0x269cff0, rpc=0x0, reply=0x25adf80) at src/session.c:2949

7 0x00007f83231306a8 in nc_session_receive (session=0x269cff0, timeout=100, msg=0x7fffd7866f58) at src/session.c:2345

8 0x00007f832313074d in nc_session_recv_msg (session=0x269cff0, timeout=100, msg=0x7fffd7866f58) at src/session.c:2363

9 0x00007f83231308bf in nc_session_recv_reply (session=0x269cff0, timeout=-1, reply=0x7fffd7867028) at src/session.c:2409

10 0x00007f832313228a in nc_session_send_recv (session=0x269cff0, rpc=0x2c10f40, reply=0x7fffd7867028) at src/session.c:3036

Regards, Parameswaran

rkrejci commented 8 years ago

Duplicates #200