From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 1CE0B3858D32; Tue, 20 Jun 2023 12:21:02 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 1CE0B3858D32 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1687263662; bh=JCet3PuLQFgBHEZSIi7HYBHSEu+uo4LS0ouvuh1EDsY=; h=From:To:Subject:Date:In-Reply-To:References:From; b=g2YxpxThC8rLDzomzPYQX+VWFH5cB8PqDgW+cJ5rgG77T/yl1BTpzqWk414npHjsJ N6VRA0XANIZ8XOiiFFLeOmVgLSKjYLCvYPVj6JNM8DwF7v7YCSeEQfFXXIGnZ1YAMk eCWUPe+H/mRlV1nGl3lFMh+AtVmQKzDkRKpsIqC8= From: "adhemerval.zanella at linaro dot org" To: glibc-bugs@sourceware.org Subject: [Bug libc/30558] SIGEV_THREAD is badly implemented Date: Tue, 20 Jun 2023 12:21:00 +0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: changed X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: glibc X-Bugzilla-Component: libc X-Bugzilla-Version: 2.37 X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: adhemerval.zanella at linaro dot org X-Bugzilla-Status: UNCONFIRMED X-Bugzilla-Resolution: X-Bugzilla-Priority: P2 X-Bugzilla-Assigned-To: unassigned at sourceware dot org X-Bugzilla-Target-Milestone: --- 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: http://sourceware.org/bugzilla/ Auto-Submitted: auto-generated MIME-Version: 1.0 List-Id: https://sourceware.org/bugzilla/show_bug.cgi?id=3D30558 --- Comment #18 from Adhemerval Zanella --- (In reply to Stas Sergeev from comment #17) > > This is defined as 'may fail', which does not bind the implementation > > to the required semantic of one thread per time expiration. >=20 > Still it is enough to make your other > claim invalid: >=20 > "Reading the SIGEV_THREAD description [1], it is not clear to me that a n= ew > thread should be created for *every* timer expiration from the same timer. > In fact, POSIX also advises against it on the timer_settime application > because of the concurrent stack usage issue [2]." >=20 > The earlier quote provided by me > is very explicit on a thread per tick, > and timer_settime doesn't advice against > that because it even defines the failure > per multiple stack usage. This means it > foresee 1 detached thread per tick, rather > than advicing against. > So we have 1 explicit quote about that, > and we have 1 that implicitly supports > that. I'd say "posix is very clear on this". I don't think so, the earlier quote (which you linked from the previous POS= IX version by the way, although it has not changed on POSIX 2017) allows both implementations. The timer_settime quote also only allows the implementati= on to return an error if the resulting timer will trigger a UB (by using the s= ame stack on multiple threads), if the implementation is not subject to such is= sue it can ignore the 'may fail'. >=20 > > This wording is a user-visible API, so not being joinable >=20 > There is no such wording. > The wording it: > "In neither case is it valid to call pthread_join()" > and you conclude it means not joinable. > But it doesn't mean so. Not being joinable means that calling pthread_join() is UB. Some implementations *might* try to catch such issues (as glibc, since it keeps = the pthread_t stack in a cache for some time), but again it is error-prone and fragile. >=20 > > And glibc does not need to join the thread >=20 > But we were discussing the user-provided > PTHREAD_CREATE_JOINABLE attribute. Which is overridden by an explicit __pthread_attr_setdetachstate (PTHREAD_CREATE_DETACHED) on timer_create. Again, not doing this results in= a tricky implementation and I think we should not move toward it. >=20 > > Afaik POSIX only defines API after a de-facto implementation > > exactly to avoid adding non-tested ones. >=20 > Maybe that was modeled after some very > old bsd impl, no idea. Linux would definitely > not start from such an impl. It is visibly > even trying to fix timer_getoverrun()'s > definition, and then re-implements the whole > thing in a timerfd. >=20 > > A DR for what exactly? >=20 > Exactly for proposing 1 detached thread > per tick in the quote I pointed. And there > were no quotes that say otherwise. > Also they should explicitly disallow > calling pthread_exit() and other things > that musl disallow. > Also they should realize that 1 thread > per tick breaks timer_getoverrun(), and > probably re-spec timer_getoverrun() > completely. > Or if they fail to do the above, then > at least they should keep supporting > passing a pthread attribute, rather > than to declare that an UB (although > this is not needed if they fix the rest). > There are the reasons for a DR here. Feel free to propose it, I think it would make some implementation non-conformant and thus will most likely be either rejected or raised to am= end by some commenter. But again, the implementation with one thread per timer should be conformant and improve current support for timer_overrun; so I se= e no strong reason to ask for DR to tie POSIX timer SIGEV_THREAD to a specific implementation that might not be the best approach. --=20 You are receiving this mail because: You are on the CC list for the bug.=