From nobody Mon Jan 17 15:14:32 2022 X-Original-To: threads@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id DBEDC19622EB for ; Mon, 17 Jan 2022 15:14:32 +0000 (UTC) (envelope-from bugzilla-noreply@freebsd.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4JcwRr58Lsz4T19 for ; Mon, 17 Jan 2022 15:14:32 +0000 (UTC) (envelope-from bugzilla-noreply@freebsd.org) Received: from kenobi.freebsd.org (kenobi.freebsd.org [IPv6:2610:1c1:1:606c::50:1d]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 8D6C710588 for ; Mon, 17 Jan 2022 15:14:32 +0000 (UTC) (envelope-from bugzilla-noreply@freebsd.org) Received: from kenobi.freebsd.org ([127.0.1.5]) by kenobi.freebsd.org (8.15.2/8.15.2) with ESMTP id 20HFEWGg013844 for ; Mon, 17 Jan 2022 15:14:32 GMT (envelope-from bugzilla-noreply@freebsd.org) Received: (from www@localhost) by kenobi.freebsd.org (8.15.2/8.15.2/Submit) id 20HFEWjT013843 for threads@FreeBSD.org; Mon, 17 Jan 2022 15:14:32 GMT (envelope-from bugzilla-noreply@freebsd.org) X-Authentication-Warning: kenobi.freebsd.org: www set sender to bugzilla-noreply@freebsd.org using -f From: bugzilla-noreply@freebsd.org To: threads@FreeBSD.org Subject: [Bug 254995] pthread_cond_timedwait() returns EDEADLK Date: Mon, 17 Jan 2022 15:14:32 +0000 X-Bugzilla-Reason: AssignedTo X-Bugzilla-Type: changed X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: Base System X-Bugzilla-Component: threads X-Bugzilla-Version: 12.1-RELEASE X-Bugzilla-Keywords: X-Bugzilla-Severity: Affects Some People X-Bugzilla-Who: nkoch@demig.de X-Bugzilla-Status: New X-Bugzilla-Resolution: X-Bugzilla-Priority: --- X-Bugzilla-Assigned-To: threads@FreeBSD.org X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: Message-ID: In-Reply-To: References: Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Bugzilla-URL: https://bugs.freebsd.org/bugzilla/ Auto-Submitted: auto-generated List-Id: Threading List-Archive: https://lists.freebsd.org/archives/freebsd-threads List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-freebsd-threads@freebsd.org X-BeenThere: freebsd-threads@freebsd.org MIME-Version: 1.0 ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1642432472; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=0Qdo14EqV91iKdkyj2zhf6zmwS5gbFS7ACkawusdU2w=; b=lJd3LwWBbo1h789eWYZo6WRtkaYPZ+LHdhskelUMurxACA/GBTPkxi2n0O6wWzS363CmM8 hN5akHSDVett9PdocfpD2q1m6QQk1hUjcQRdSIjEHWgKsTeiMnZZK0xsf2L6E+UaQwr3Fh Rn6wFDlS9fHhcJ9FdyPT1NT7Rmvn0N4rfUIJEbdjzzCTEbWlf2+29dCKTfe7GaYf8KE0TD EWhpZOZMsv+XGEpCtRWergCkOITGzdQthmYAMBtN6eQeYOtGrlsolu4z8BHEx4K+qqWbhq jAjt+do5Maz2knE0n4VkvLj8aM7B4teoVArTJs/PNpUnNyPUxWVUvk/9I9CpZA== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1642432472; a=rsa-sha256; cv=none; b=wYKQTwKimNVlkncA8+WQZrBZ5Yq3MBIsKNEOzeQcJXgx36B1p6SJUIDta9abuW+nfgXk31 efouYCikczozrla/+vAdykQtlXm7ZJ8IwDJUqSJZZao9koFyVbHDxOkiuE3LzuXe27E7wx 7KQhGe0vJoNYvDc+mU9tZ200Y4RfjNaid3BD5dtjkBBFRkFyXPvntDaTXVxCX8VDDl6gbt YUYytHc7ushIh7/2QnAyioVLBZKubMTjSAjFxoW6/qLqybW9xuoDJvC+9PHDsV4UU7vTXn wxow7fnoBvyoWMu8pOcaKBqIjPriUSxDCe3X6F1EvGIFYd1h95yo5Xul+lwH7Q== ARC-Authentication-Results: i=1; mx1.freebsd.org; none X-ThisMailContainsUnwantedMimeParts: N https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=3D254995 --- Comment #12 from nkoch@demig.de --- I modified the kernel code as suggested. I also put some printf's into libthr. After a longer time of testing I had the deadlock again: mutex_self_lock(struct pthread_mutex *m, const struct timespec *abstime) { struct timespec ts1, ts2; int ret; switch (PMUTEX_TYPE(m->m_flags)) { case PTHREAD_MUTEX_ERRORCHECK: case PTHREAD_MUTEX_ADAPTIVE_NP: if (abstime) { if (abstime->tv_sec < 0 || abstime->tv_nsec < 0 || abstime->tv_nsec >=3D 1000000000) { ret =3D EINVAL; } else { clock_gettime(CLOCK_REALTIME, &ts1); TIMESPEC_SUB(&ts2, abstime, &ts1); __sys_nanosleep(&ts2, NULL); ret =3D ETIMEDOUT; } } else { /* * POSIX specifies that mutexes should return * EDEADLK if a recursive lock is detected. */ #if !defined(_PTHREADS_INVARIANTS) #error #endif ret =3D EDEADLK; ******** thread 0x6883500(0x1871a), mutex 0x653e800 own 0x1871a list 0x0 0x0 err=3D11 } ******** called from mutex_lock_sleep(): mutex_lock_sleep(struct pthread *curthread, struct pthread_mutex *m, const struct timespec *abstime) { uint32_t id, owner; int count, ret; id =3D TID(curthread); if (PMUTEX_OWNER_ID(m) =3D=3D id) >>>>>>>> return (mutex_self_lock(m, abstime)); ******** called from mutex_lock_common(): mutex_lock_common(struct pthread_mutex *m, const struct timespec *abstime, bool cvattach, bool rb_onlist) { struct pthread *curthread; int ret, robust; robust =3D 0; /* pacify gcc */ curthread =3D _get_curthread(); if (!cvattach && m->m_flags & PMUTEX_FLAG_PRIVATE) THR_CRITICAL_ENTER(curthread); if (!rb_onlist) robust =3D _mutex_enter_robust(curthread, m); ret =3D _thr_umutex_trylock2(&m->m_lock, TID(curthread)); if (ret =3D=3D 0 || ret =3D=3D EOWNERDEAD) { enqueue_mutex(curthread, m, ret); if (ret =3D=3D EOWNERDEAD) m->m_lock.m_flags |=3D UMUTEX_NONCONSISTENT; } else { >>>>>>>> ret =3D mutex_lock_sleep(curthread, m, abstime); } ******** called from _mutex_cv_lock(): _mutex_cv_lock(struct pthread_mutex *m, int count, bool rb_onlist) { int error; struct pthread_mutex saved =3D *m; error =3D mutex_lock_common(m, NULL, true, rb_onlist); if (error =3D=3D 0 || error =3D=3D EOWNERDEAD) m->m_count =3D count; else if (error =3D=3D EDEADLK) ******** thread 0x6883500(0x1871a), mutex 0x653e800 own 0x1871a(0x1871a) li= st 0x0(0x0) 0x0(0x0) err=3D11 return (error); } ********called from cond_wait_kernel(): cond_wait_kernel(struct pthread_cond *cvp, struct pthread_mutex *mp, const struct timespec *abstime, int cancel) { struct pthread *curthread; int error, error2, recurse, robust; curthread =3D _get_curthread(); robust =3D _mutex_enter_robust(curthread, mp); error =3D _mutex_cv_detach(mp, &recurse); if (error !=3D 0) { if (robust) _mutex_leave_robust(curthread, mp); return (error); } if (cancel) _thr_cancel_enter2(curthread, 0); error =3D _thr_ucond_wait(&cvp->kcond, &mp->m_lock, abstime, CVWAIT_ABSTIME | CVWAIT_CLOCKID); if (cancel) _thr_cancel_leave(curthread, 0); /* * Note that PP mutex and ROBUST mutex may return * interesting error codes. */ if (error =3D=3D 0) { error2 =3D _mutex_cv_lock(mp, recurse, true); } else if (error =3D=3D EINTR || error =3D=3D ETIMEDOUT) { error2 =3D _mutex_cv_lock(mp, recurse, true); /* * Do not do cancellation on EOWNERDEAD there. The * cancellation cleanup handler will use the protected * state and unlock the mutex without making the state * consistent and the state will be unrecoverable. */ if (error2 =3D=3D 0 && cancel) { if (robust) { _mutex_leave_robust(curthread, mp); robust =3D false; } _thr_testcancel(curthread); } else ******** error 11: 0x6883500(0x1871a)error2, curthread, TID(curthread)); --=20 You are receiving this mail because: You are the assignee for the bug.=