public inbox for glibc-bugs@sourceware.org help / color / mirror / Atom feed
From: "arun11299 at gmail dot com" <sourceware-bugzilla@sourceware.org> To: glibc-bugs@sourceware.org Subject: [Bug nptl/25847] pthread_cond_signal failed to wake up pthread_cond_wait due to a bug in undoing stealing Date: Tue, 05 May 2020 11:50:46 +0000 [thread overview] Message-ID: <bug-25847-131-MEPPjNE5Wp@http.sourceware.org/bugzilla/> (raw) In-Reply-To: <bug-25847-131@http.sourceware.org/bugzilla/> https://sourceware.org/bugzilla/show_bug.cgi?id=25847 Arun <arun11299 at gmail dot com> changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |arun11299 at gmail dot com --- Comment #3 from Arun <arun11299 at gmail dot com> --- I am probably facing the same issue with Python as well where GIL (Global Interpreter Lock) is the one locking the critical region of code. My setup involves spawning 4 to 8 Python threads and each thread would be making lots of Redis socket calls. Python releases the GIL whenever a socket call is made so that other threads can make some progress. Below is the backtrace of the thread which was supposed to release the GIL by doing a condition signal first. ------------------- (gdb) bt #0 0x00007f12c99e04b0 in futex_wait (private=<optimized out>, expected=4, futex_word=0xa745b0 <gil_cond+16>) at ../sysdeps/unix/sysv/linux/futex-internal.h:61 #1 0x00007f12c99e04b0 in futex_wait_simple (private=<optimized out>, expected=4, futex_word=0xa745b0 <gil_cond+16>) at ../sysdeps/nptl/futex-internal.h:135 #2 0x00007f12c99e04b0 in __condvar_quiesce_and_switch_g1 (private=<optimized out>, g1index=<synthetic pointer>, wseq=<optimized out>, cond=0xa745a0 <gil_cond>) at pthread_cond_common.c:412 #3 0x00007f12c99e04b0 in __pthread_cond_signal (cond=0xa745a0 <gil_cond>) at pthread_cond_signal.c:78 #4 0x000000000050bfc8 in drop_gil.lto_priv (tstate=0x146ee3f0) at ../Python/ceval_gil.h:187 #5 0x000000000050c0ed in PyEval_SaveThread () at ../Python/ceval.c:356 #6 0x00000000005c04bb in sock_call_ex (s=0x7f125b97a9a8, writing=1, sock_func= 0x5bdbf0 <sock_send_impl>, data=0x7f12594650a0, connect=0, err=0x0, timeout=-1000000000) at ../Modules/socketmodule.c:899 #7 0x00000000005c0659 in sock_sendall (s=0x7f125b97a9a8, args=<optimized out>) at ../Modules/socketmodule.c:3833 #8 0x000000000050a8af in _PyCFunction_FastCallDict (kwargs=<optimized out>, nargs=<optimized out>, args=<optimized out>, func_obj=<built-in method sendall of socket object at remote 0x7f125b97a9a8>) at ../Objects/methodobject.c:234 #9 0x000000000050a8af in _PyCFunction_FastCallKeywords (kwnames=<optimized out>, nargs=<optimized out>, stack=<optimized out>, func=<optimized out>) at ../Objects/methodobject.c:294 #10 0x000000000050a8af in call_function.lto_priv (pp_stack=0x7f1259465250, oparg=<optimized out>, kwnames=<optimized out>) at ../Python/ceval.c:4851 #11 0x000000000050c5b9 in _PyEval_EvalFrameDefault (f=<optimized out>, throwflag=<optimized out>) at ../Python/ceval.c:3335 #12 0x0000000000509d48 in PyEval_EvalFrameEx (throwflag=0, f=Frame 0x16cdcbf8, for file /usr/lib/python3/dist-packages/redis/connection.py, line 590, in send_packed_command (self=<Connection(pid=12668, host='10.64.219.4', port=6379, db=0, password=None, socket_timeout=None, socket_connect_timeout=None, socket_keepalive=None, socket_keepalive_options={}, retry_on_timeout=False, encoder=<Encoder(encoding='utf-8', encoding_errors='strict', decode_responses=True) at remote 0x7f1259c84be0>, _sock=<socket at remote 0x7f125b97a9a8>, _parser=<HiredisParser(socket_read_size=65536, _buffer=<bytearray at remote 0x7f1259c848b8>, _sock=<...>, _reader=<hiredis.Reader at remote 0x7f1259c8b0c0>, _next_response=False) at remote 0x7f1259c84518>, _description_args={'host': '10.64.219.4', 'port': 6379, 'db': 0}, _connect_callbacks=[]) at remote 0x7f1259c84ba8>, command=[b'*2\r\n$3\r\nGET\r\n$54\r\nproj_00|mock1|cps|07b6e3d7-5ed1-36e8-81ef-e53777298405\r\n'], item=b'*2\r\n$3\r\nGET\r\n$54\r\nproj_00|mock1|cps|07b6e3d7-5ed1-36e8-81ef-e53777298405\r\n')) at ../Python/ceval.c:754 #13 0x0000000000509d48 in _PyFunction_FastCall (globals=<optimized out>, nargs=382585848, args=<optimized out>, co=<optimized out>) at ../Python/ceval.c:4933 ------------------- Part of the python code that drops the GIL: -------------------- static void drop_gil(struct _ceval_runtime_state *ceval, PyThreadState *tstate) { struct _gil_runtime_state *gil = &ceval->gil; if (!_Py_atomic_load_relaxed(&gil->locked)) { Py_FatalError("drop_gil: GIL is not locked"); } /* tstate is allowed to be NULL (early interpreter init) */ if (tstate != NULL) { /* Sub-interpreter support: threads might have been switched under our feet using PyThreadState_Swap(). Fix the GIL last holder variable so that our heuristics work. */ _Py_atomic_store_relaxed(&gil->last_holder, (uintptr_t)tstate); } MUTEX_LOCK(gil->mutex); _Py_ANNOTATE_RWLOCK_RELEASED(&gil->locked, /*is_write=*/1); _Py_atomic_store_relaxed(&gil->locked, 0); COND_SIGNAL(gil->cond); MUTEX_UNLOCK(gil->mutex); #ifdef FORCE_SWITCHING if (_Py_atomic_load_relaxed(&ceval->gil_drop_request) && tstate != NULL) { MUTEX_LOCK(gil->switch_mutex); /* Not switched yet => wait */ if (((PyThreadState*)_Py_atomic_load_relaxed(&gil->last_holder)) == tstate) { assert(is_tstate_valid(tstate)); RESET_GIL_DROP_REQUEST(tstate->interp); /* NOTE: if COND_WAIT does not atomically start waiting when releasing the mutex, another thread can run through, take the GIL and drop it again, and reset the condition before we even had a chance to wait for it. */ COND_WAIT(gil->switch_cond, gil->switch_mutex); } MUTEX_UNLOCK(gil->switch_mutex); } #endif } -------------------- -- You are receiving this mail because: You are on the CC list for the bug.
next prev parent reply other threads:[~2020-05-05 11:50 UTC|newest] Thread overview: 93+ messages / expand[flat|nested] mbox.gz Atom feed top 2020-04-18 8:04 [Bug nptl/25847] New: " qin.li at thetradedesk dot com 2020-04-18 8:07 ` [Bug nptl/25847] " qin.li at thetradedesk dot com 2020-04-20 17:52 ` qin.li at thetradedesk dot com 2020-05-05 11:50 ` arun11299 at gmail dot com [this message] 2020-05-05 11:52 ` arun11299 at gmail dot com 2020-05-14 8:52 ` dingxiangfei2009 at protonmail dot ch 2020-05-19 21:15 ` carlos at redhat dot com 2020-10-08 19:07 ` michael.bacarella at gmail dot com 2020-10-10 8:11 ` flo at geekplace dot eu 2020-10-12 20:53 ` anssi.hannula at iki dot fi 2020-10-13 16:50 ` guillaume at morinfr dot org 2020-10-16 20:23 ` kirichenkoga at gmail dot com 2020-10-18 22:55 ` michael.bacarella at gmail dot com 2020-10-20 20:12 ` kirichenkoga at gmail dot com 2020-10-20 20:17 ` kirichenkoga at gmail dot com 2020-11-01 13:58 ` malteskarupke at fastmail dot fm 2020-11-01 15:40 ` michael.bacarella at gmail dot com 2020-11-15 2:45 ` malteskarupke at fastmail dot fm 2020-11-23 10:37 ` ydroneaud at opteya dot com 2020-11-23 16:36 ` mattst88 at gmail dot com 2020-11-23 16:46 ` adhemerval.zanella at linaro dot org 2020-12-07 15:41 ` balint at balintreczey dot hu 2020-12-09 3:22 ` malteskarupke at fastmail dot fm 2020-12-24 20:02 ` triegel at redhat dot com 2020-12-25 16:19 ` triegel at redhat dot com 2021-01-07 1:09 ` manojgupta at google dot com 2021-01-07 7:31 ` balint at balintreczey dot hu 2021-01-07 13:54 ` malteskarupke at fastmail dot fm 2021-01-07 20:43 ` triegel at redhat dot com 2021-01-07 23:31 ` triegel at redhat dot com 2021-01-08 3:45 ` malteskarupke at fastmail dot fm 2021-01-16 0:21 ` triegel at redhat dot com 2021-01-16 0:23 ` triegel at redhat dot com 2021-01-30 0:59 ` michael.bacarella at gmail dot com 2021-02-07 17:38 ` slav.isv at gmail dot com 2021-03-09 15:18 ` bugdal at aerifal dot cx 2021-04-06 0:37 ` frankbarrus_sw at shaggy dot cc 2021-04-06 1:17 ` frankbarrus_sw at shaggy dot cc 2021-04-06 14:32 ` frankbarrus_sw at shaggy dot cc 2021-04-06 16:49 ` frankbarrus_sw at shaggy dot cc 2021-04-11 12:12 ` carlos at redhat dot com 2021-04-11 12:13 ` carlos at redhat dot com 2021-04-13 12:21 ` frankbarrus_sw at shaggy dot cc 2021-04-14 16:57 ` qin.li at thetradedesk dot com 2021-04-15 14:13 ` frankbarrus_sw at shaggy dot cc 2021-04-15 14:34 ` frankbarrus_sw at shaggy dot cc 2021-04-30 17:41 ` venkiram_be at yahoo dot co.in 2021-05-04 22:48 ` frankbarrus_sw at shaggy dot cc 2021-05-04 22:51 ` frankbarrus_sw at shaggy dot cc 2021-05-04 22:58 ` frankbarrus_sw at shaggy dot cc 2021-05-13 13:25 ` tuliom at ascii dot art.br 2021-06-14 13:31 ` willireamangel at gmail dot com 2021-07-09 1:41 ` uwydoc at gmail dot com 2021-07-15 0:55 ` benh at kernel dot crashing.org 2021-08-16 9:41 ` evgeny+sourceware at loop54 dot com 2021-09-13 16:50 ` dushistov at mail dot ru 2021-09-22 19:03 ` evgeny+sourceware at loop54 dot com 2021-09-22 19:07 ` balint at balintreczey dot hu 2021-09-24 0:18 ` tuliom at ascii dot art.br 2021-09-24 0:58 ` michael.bacarella at gmail dot com 2021-09-29 11:50 ` fweimer at redhat dot com 2021-10-21 15:42 ` fweimer at redhat dot com 2021-10-30 22:17 ` sam at gentoo dot org 2021-11-25 14:49 ` arekm at maven dot pl 2022-09-18 5:38 ` malteskarupke at fastmail dot fm 2022-09-18 20:06 ` carlos at redhat dot com 2022-09-19 3:38 ` malteskarupke at fastmail dot fm 2022-09-24 0:03 ` bugzilla at dimebar dot com 2022-09-24 10:15 ` ismail at i10z dot com 2022-09-26 14:28 ` ehagberg at janestreet dot com 2022-09-26 14:32 ` ehagberg at janestreet dot com 2022-10-06 21:58 ` malteskarupke at fastmail dot fm 2022-10-07 12:01 ` crrodriguez at opensuse dot org 2022-10-15 19:57 ` malteskarupke at fastmail dot fm 2022-11-07 18:23 ` sourceware-bugzilla at djr61 dot uk 2023-01-28 14:57 ` malteskarupke at fastmail dot fm 2023-05-01 12:52 ` carlos at redhat dot com 2023-05-02 12:57 ` carlos at redhat dot com 2023-05-03 3:04 ` malteskarupke at fastmail dot fm 2023-05-04 4:57 ` malteskarupke at fastmail dot fm 2023-05-04 12:24 ` carlos at redhat dot com 2023-05-05 23:44 ` carlos at redhat dot com 2023-05-10 21:29 ` frankbarrus_sw at shaggy dot cc 2023-05-10 21:39 ` frankbarrus_sw at shaggy dot cc 2023-05-11 0:22 ` frankbarrus_sw at shaggy dot cc 2023-05-11 12:01 ` carlos at redhat dot com 2023-05-11 12:05 ` carlos at redhat dot com 2023-05-13 4:10 ` malteskarupke at fastmail dot fm 2023-08-24 20:24 ` jwakely.gcc at gmail dot com 2023-09-26 12:33 ` malteskarupke at fastmail dot fm 2023-09-26 12:38 ` fweimer at redhat dot com 2024-01-05 7:31 ` malteskarupke at fastmail dot fm 2024-02-17 9:44 ` github at kalvdans dot no-ip.org
Reply instructions: You may reply publicly to this message via plain-text email using any one of the following methods: * Save the following mbox file, import it into your mail client, and reply-to-all from there: mbox Avoid top-posting and favor interleaved quoting: https://en.wikipedia.org/wiki/Posting_style#Interleaved_style * Reply using the --to, --cc, and --in-reply-to switches of git-send-email(1): git send-email \ --in-reply-to=bug-25847-131-MEPPjNE5Wp@http.sourceware.org/bugzilla/ \ --to=sourceware-bugzilla@sourceware.org \ --cc=glibc-bugs@sourceware.org \ /path/to/YOUR_REPLY https://kernel.org/pub/software/scm/git/docs/git-send-email.html * If your mail client supports setting the In-Reply-To header via mailto: links, try the mailto: linkBe sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox; as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).