From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on dcvr.yhbt.net X-Spam-Level: X-Spam-ASN: AS31976 209.132.180.0/23 X-Spam-Status: No, score=-3.7 required=3.0 tests=AWL,BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_EF,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,RCVD_IN_DNSWL_MED,SPF_HELO_PASS,SPF_PASS shortcircuit=no autolearn=ham autolearn_force=no version=3.4.2 Received: from sourceware.org (server1.sourceware.org [209.132.180.131]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dcvr.yhbt.net (Postfix) with ESMTPS id CDF35211B5 for ; Mon, 14 Jan 2019 16:34:42 +0000 (UTC) DomainKey-Signature: a=rsa-sha1; c=nofws; d=sourceware.org; h=list-id :list-unsubscribe:list-subscribe:list-archive:list-post :list-help:sender:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc:content-type; q=dns; s=default; b=Llp0 /qoIXR7PHuIuYxFtn3KQP3SFkcTgeUhGukpB33XP7C7VBJx8srZnyqrkVFvfagLI l00XlzmPUjONm8l9+kE4vrzCzlTsZHpQE29JCyR3ujEbEdp4VBxWy0sXHjicE5XD juntT074Nuzv4f2y0suAn+lcNfm4YgDZigBALb8= DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=sourceware.org; h=list-id :list-unsubscribe:list-subscribe:list-archive:list-post :list-help:sender:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc:content-type; s=default; bh=pWo3/zo6WU 0XJKceAWz+fC5Vn3U=; b=fjQXfy8dkPvwMIvdnge9Q7D9QMBfiBKKTcRFU+hcZM 6/bkma9qOMTXyMAWOYdqszB5ahM/vayNpuCrJq5+nzYebOPDCueU3Fl7kN7qHIZS E4hy2s8E7pwGY0d6WskH9CE2tkv/H9/1bqSUG2+2glTWcVp4/Bk/A7255wyBdBIY c= Received: (qmail 122799 invoked by alias); 14 Jan 2019 16:34:40 -0000 Mailing-List: contact libc-alpha-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: libc-alpha-owner@sourceware.org Received: (qmail 122628 invoked by uid 89); 14 Jan 2019 16:34:40 -0000 Authentication-Results: sourceware.org; auth=none X-HELO: mailbackend.panix.com MIME-Version: 1.0 References: <874lafezhe.fsf@oldenburg2.str.redhat.com> <87sgxzdjl4.fsf@oldenburg2.str.redhat.com> <61925098-4669-b478-9baf-644818d26a44@arm.com> <32971978-77ca-57f4-2524-560f53008be4@linaro.org> In-Reply-To: <32971978-77ca-57f4-2524-560f53008be4@linaro.org> From: Zack Weinberg Date: Mon, 14 Jan 2019 11:34:22 -0500 Message-ID: Subject: Re: Fwd: What can a signal handler do with SIGSTKSZ? To: Adhemerval Zanella Cc: GNU C Library Content-Type: text/plain; charset="UTF-8" On Mon, Jan 14, 2019 at 6:29 AM Adhemerval Zanella wrote: > On 14/01/2019 09:18, Szabolcs Nagy wrote: > > > > as far as i know aarch64 kernel calculates and reports worst > > case stack frame size precisely, so that's probably just an > > x86 issue. That's good to hear. All of the architectures' signal frame construction code should be checked and updated if necessary -- alas, I doubt there's any good way to automate the problem, since signal delivery is so low-level and arch-specific (but I'm not a kernel hacker). > > i think proposing sysconf(_SC_{MIN}SIGSTKSZ) for posix is the > > right solution with the kernel providing an upper bound of the > > stack frame in AT_MINSIGSTKSZ (as it already does on aarch64). > > > > with the current wording of the standard SIGSTKSZ and MINSIGSTKSZ > > definition cannot be omitted when they are runtime variables, > > so posix needs to be updated. > > From an implementation standpoint, how the lib would calculate _SC_SIGSTKSZ? > Just plus constant based on _SC_MINSIGSTKSZ? If it is the idea we might go > only with _SC_MINSIGSSTKSZ and export the value adjustment instead. That seems fine to me. For this new interface, the backward compatibility concerns I raised regarding what you can do in MINSIGSTKSZ don't necessarily apply, and it would make sense for it to be truly a minimum. I would suggest we define "minimum" in terms of what the C standard - not POSIX - allows you to do in a signal handler, which is almost nothing: you're guaranteed to have enough space in sysconf(_SC_MINSIGSTKSZ) for this: static volatile sig_atomic_t signal_flag = 0; static void handler(int unused) { flag = 1; } and this: static atomic_uint signal_count = 0; static void handler (int unused) { atomic_fetch_add (&signal_count, 1); } but *not* for this: static int sockets[MAX_SOCKETS]; static void handler (int sig) { for (int i = 0; i < MAX_SOCKETS; i++) { if (sockets[i] == -1) continue; write (sockets[i], "\r\n500 Service shutting down unexpectedly\r\n\r\n", 44); close (sockets[i]); } signal (sig, SIG_DFL); raise (sig); } or for anything for which you would need to use SA_SIGINFO, or for recursive signal delivery. zw