public inbox for glibc-bugs@sourceware.org help / color / mirror / Atom feed
From: "adhemerval.zanella at linaro dot org" <sourceware-bugzilla@sourceware.org> To: glibc-bugs@sourceware.org Subject: [Bug libc/30558] SIGEV_THREAD is badly implemented Date: Tue, 20 Jun 2023 12:21:00 +0000 [thread overview] Message-ID: <bug-30558-131-puZAMdKnKP@http.sourceware.org/bugzilla/> (raw) In-Reply-To: <bug-30558-131@http.sourceware.org/bugzilla/> https://sourceware.org/bugzilla/show_bug.cgi?id=30558 --- Comment #18 from Adhemerval Zanella <adhemerval.zanella at linaro dot org> --- (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. > > Still it is enough to make your other > claim invalid: > > "Reading the SIGEV_THREAD description [1], it is not clear to me that a new > 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]." > > 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 POSIX version by the way, although it has not changed on POSIX 2017) allows both implementations. The timer_settime quote also only allows the implementation to return an error if the resulting timer will trigger a UB (by using the same stack on multiple threads), if the implementation is not subject to such issue it can ignore the 'may fail'. > > > This wording is a user-visible API, so not being joinable > > 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. > > > And glibc does not need to join the thread > > 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. > > > Afaik POSIX only defines API after a de-facto implementation > > exactly to avoid adding non-tested ones. > > 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. > > > A DR for what exactly? > > 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 amend by some commenter. But again, the implementation with one thread per timer should be conformant and improve current support for timer_overrun; so I see no strong reason to ask for DR to tie POSIX timer SIGEV_THREAD to a specific implementation that might not be the best approach. -- You are receiving this mail because: You are on the CC list for the bug.
next prev parent reply other threads:[~2023-06-20 12:21 UTC|newest] Thread overview: 32+ messages / expand[flat|nested] mbox.gz Atom feed top 2023-06-15 19:36 [Bug libc/30558] New: " stsp at users dot sourceforge.net 2023-06-15 21:04 ` [Bug libc/30558] " adhemerval.zanella at linaro dot org 2023-06-16 2:23 ` stsp at users dot sourceforge.net 2023-06-16 6:44 ` stsp at users dot sourceforge.net 2023-06-16 7:29 ` stsp at users dot sourceforge.net 2023-06-16 7:51 ` stsp at users dot sourceforge.net 2023-06-16 11:44 ` stsp at users dot sourceforge.net 2023-06-19 17:41 ` adhemerval.zanella at linaro dot org 2023-06-19 18:54 ` stsp at users dot sourceforge.net 2023-06-19 19:33 ` adhemerval.zanella at linaro dot org 2023-06-19 19:48 ` stsp at users dot sourceforge.net 2023-06-19 20:14 ` adhemerval.zanella at linaro dot org 2023-06-19 20:26 ` stsp at users dot sourceforge.net 2023-06-19 21:15 ` adhemerval.zanella at linaro dot org 2023-06-19 21:21 ` adhemerval.zanella at linaro dot org 2023-06-19 21:58 ` stsp at users dot sourceforge.net 2023-06-19 22:51 ` adhemerval.zanella at linaro dot org 2023-06-20 4:14 ` stsp at users dot sourceforge.net 2023-06-20 12:21 ` adhemerval.zanella at linaro dot org [this message] 2023-06-20 12:49 ` stsp at users dot sourceforge.net 2023-06-20 13:01 ` adhemerval.zanella at linaro dot org 2023-06-20 13:13 ` stsp at users dot sourceforge.net 2023-06-21 3:19 ` stsp at users dot sourceforge.net 2023-06-21 14:32 ` adhemerval.zanella at linaro dot org 2023-06-21 14:41 ` stsp at users dot sourceforge.net 2023-06-21 14:43 ` adhemerval.zanella at linaro dot org 2023-06-21 14:52 ` stsp at users dot sourceforge.net 2023-06-21 15:07 ` adhemerval.zanella at linaro dot org 2023-06-22 2:57 ` bugdal at aerifal dot cx 2023-06-22 5:23 ` stsp at users dot sourceforge.net 2023-06-23 18:34 ` adhemerval.zanella at linaro dot org 2023-06-24 17:03 ` crrodriguez at opensuse dot 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-30558-131-puZAMdKnKP@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).