From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-pg1-x536.google.com (mail-pg1-x536.google.com [IPv6:2607:f8b0:4864:20::536]) by sourceware.org (Postfix) with ESMTPS id 3F9423858D28 for ; Mon, 1 Aug 2022 08:31:08 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 3F9423858D28 Received: by mail-pg1-x536.google.com with SMTP id 23so9082104pgc.8 for ; Mon, 01 Aug 2022 01:31:08 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc:content-transfer-encoding; bh=/RKKElzVeh5WMwNTlz/Tc8Hzuy3GOEraCwfIJ0Q8nEg=; b=lijtBFVr2Dlb1w/32ZqH0qV6MkNai9ADbYP59VPqhQcm5qnGfG0aoCNaoMMmDGXjiS d6Av/bUyPX+sE9jlHUr590StmLp3uYuFLbpgqmjtbKWbcbHuNVURVMNlSM8Mkix33cIF cEkBNsDbJ2W9LCZrUlbDzaqAmeDyNcyaQ9SCubNihZmItDLHbbRKqnrVk/RiQ+pe5kxW YJHAO1hgUGO2q/5dPZsLLMLdU6G1iqRhhSqnqteEDoo4nPfors3B+OHkAMfnwl/UVrEL UweQ7lay9/vCFZvEnISg54lGuw2B4Q4AFyCdPlv+o156IICdwoMd1TCkySXw0+FDx3zA Tzag== X-Gm-Message-State: AJIora/COG1UU6WF5qQfvPuZk9w3rwFY5suxLnVf2U5eP4LdgzYTDQ7s qtPNwxQm+n24Eb2dHSO4IGTfi2O68WO4HGNMIRQ= X-Google-Smtp-Source: AGRyM1sVcXLY+Lxu4/mR6U7WZALJFF4uZtj2pJO3/qbzMIOOH4RnFVBWecBGCPia0LAP7phA7aW7xHNJWbEEBrlvuNA= X-Received: by 2002:a65:6a52:0:b0:41b:6cd:dfd3 with SMTP id o18-20020a656a52000000b0041b06cddfd3mr12225363pgu.545.1659342667281; Mon, 01 Aug 2022 01:31:07 -0700 (PDT) MIME-Version: 1.0 References: In-Reply-To: From: =?UTF-8?B?Sm/Dq2wgS3LDpGhlbWFubg==?= Date: Mon, 1 Aug 2022 10:28:30 +0200 Message-ID: Subject: Re: pthread_mutex_timedlock() vs. clock_settime() To: Sebastian Huber Cc: libc-help@sourceware.org Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Spam-Status: No, score=-0.6 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, FREEMAIL_FROM, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org X-BeenThere: libc-help@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Libc-help mailing list List-Unsubscribe: , List-Archive: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 01 Aug 2022 08:31:12 -0000 Hi, pthread_mutex_t mtx of struct test_context. You lock it in line 503 first, then you call test_timeout_finite(), which calls event_post() in run() second lock. cheers, Jo=C3=ABl On Mon, Aug 1, 2022 at 9:52 AM Sebastian Huber wrote: > > Hello Jo=C3=ABl, > > On 01/08/2022 09:10, Jo=C3=ABl Kr=C3=A4hemann wrote: > > Hi Sebastian, > > > > You have a dead-lock, probably. I just looked at your code. You are > > using non-recursive mutices and I think this mutex was locked twice by > > the very same thread. > > thanks for having a look at the test case. Sorry for being so blind, but > which mutex is where in the code locked twice by the same thread? > > If I omit the mutex test case by starting with ACTION_CND_WAIT: > > for (action =3D ACTION_CND_WAIT; action < ACTION_TERMINATE; ++action) = { > event_post(&ctx->action, action); > > Then the test runs fine: > > *** timeout finite *** > pthread_cond_timedwait > wake up > pthread_cond_timedwait: actual 'Connection timed out', expected > 'Connection timed out' > pthread_rwlock_timedrdlock > wake up > pthread_rwlock_timedrdlock: actual 'Connection timed out', expected > 'Connection timed out' > pthread_rwlock_timedwrlock > wake up > pthread_rwlock_timedwrlock: actual 'Connection timed out', expected > 'Connection timed out' > sem_timedwait > wake up > sem_timedwait: actual 'Connection timed out', expected 'Connection timed > out' > mq_send > mq_timedsend > wake up > mq_timedsend: actual 'Connection timed out', expected 'Connection timed o= ut' > mq_receive > mq_timedreceive > wake up > mq_timedreceive: actual 'Connection timed out', expected 'Connection > timed out' > clock_nanosleep > wake up > clock_nanosleep: actual 'Success', expected 'Success' > > -- > embedded brains GmbH > Herr Sebastian HUBER > Dornierstr. 4 > 82178 Puchheim > Germany > email: sebastian.huber@embedded-brains.de > phone: +49-89-18 94 741 - 16 > fax: +49-89-18 94 741 - 08 > > Registergericht: Amtsgericht M=C3=BCnchen > Registernummer: HRB 157899 > Vertretungsberechtigte Gesch=C3=A4ftsf=C3=BChrer: Peter Rasmussen, Thomas= D=C3=B6rfler > Unsere Datenschutzerkl=C3=A4rung finden Sie hier: > https://embedded-brains.de/datenschutzerklaerung/