From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED!not-for-mail From: "H.J. Lu" Newsgroups: gmane.comp.lib.glibc.alpha Subject: Re: [PATCH 0/2] nptl: Update struct pthread_unwind_buf Date: Sun, 25 Feb 2018 19:55:05 -0800 Message-ID: References: <20180201205757.51911-1-hjl.tools@gmail.com> <2a02aac9-6aa3-4dc6-b122-039ae85365e8@redhat.com> <87d11emoap.fsf@mid.deneb.enyo.de> <878tc2mkgr.fsf@mid.deneb.enyo.de> <90d3ee18-c292-117f-a0c1-7822e340ca02@redhat.com> <87a7vyjsqv.fsf@mid.deneb.enyo.de> <87vaelbetu.fsf@mid.deneb.enyo.de> <87fu5pb7ql.fsf@mid.deneb.enyo.de> <877er1b4zp.fsf@mid.deneb.enyo.de> <87371pb3ga.fsf@mid.deneb.enyo.de> <87tvu59o21.fsf@mid.deneb.enyo.de> <87po4t9mxt.fsf@mid.deneb.enyo.de> NNTP-Posting-Host: blaine.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset="UTF-8" X-Trace: blaine.gmane.org 1519617192 18837 195.159.176.226 (26 Feb 2018 03:53:12 GMT) X-Complaints-To: usenet@blaine.gmane.org NNTP-Posting-Date: Mon, 26 Feb 2018 03:53:12 +0000 (UTC) Cc: "Carlos O'Donell" , GNU C Library To: Florian Weimer Original-X-From: libc-alpha-return-90571-glibc-alpha=m.gmane.org@sourceware.org Mon Feb 26 04:53:07 2018 Return-path: Envelope-to: glibc-alpha@blaine.gmane.org 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:in-reply-to:references:from:date :message-id:subject:to:cc:content-type; q=dns; s=default; b=xhc5 kAQiivti7+Ap1JFr8j7b3IieRv4+9GT+ZU4hc3MO/fIQW4S3WsxV6FYVTv+8as+w IvbVLutSWN0tM/x9k8Ee1r9S2ZBWsIHcwXAGWd9Qt7RXArPqbiQydFAr2iuoq9oz az0btMqVKjWIdrTQSXcqLfd+UZkBxeeYmuRmawM= 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:in-reply-to:references:from:date :message-id:subject:to:cc:content-type; s=default; bh=6m8jlek36m hn1fU5JCeSBQ0cGbE=; b=uL65QtsOOLiOzHHA4lAErOcRQuhFq2kwaulF7yimPr cD5VQIOcr6dlxDGKFkjjo8VYRTgsGjZngerJARWJZyvR7jfG1o64rzSdTod/JuQV zLvYYyA44o6kiC1xWQoxvyoMBVTn//oVjQGrcLIaB3RDZzY8NRR3Kv5q2QQd2ki9 U= 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: , Original-Sender: libc-alpha-owner@sourceware.org Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-2.8 required=5.0 tests=AWL,BAYES_00,FREEMAIL_FROM,RCVD_IN_DNSWL_NONE,SPF_PASS autolearn=ham version=3.3.2 spammy= X-HELO: mail-oi0-f66.google.com X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:in-reply-to:references:from:date :message-id:subject:to:cc; bh=8inyQ5emWsEs3K1j6xRixx9OUnjxkhRNAsRy1HS9M08=; b=XROoeRo1zahP4W5Ey6szmIfZnwmFByvp5E09kF0L+R4SEI1jXgFmTFTJChIJkFOXbq a2iW1KIbc0OjKtmGw8qq/svKT3awhQaF6HcWwGXIxVZd62asnEp5o+r4FokJ+VaWcnLl fzifgpS1LmqAiVT78F2+vDKybC5XVeHSoo1AohIV1Ic6hw2kXlwNIWwvMRs+rDDQBVjf /uWQdwzhYJd2depsqbagcfgVS3mzfVeXmBdNCwqqLPb9h8DauZUWEBe0xBrjKrZcFJAm swWzrMnSvUvrTQUBub4UXTgBfHN04eazkKeEriJOIeqSLXmPgb1HzFvppn4G7oltoAwo 0vCg== X-Gm-Message-State: APf1xPDigH9fzg26rL6KmrIZePcnMBFuxLXAFO+231zr0G+jjdY/T1Oc chUFCz6S327tX4LFo8W30397ll94yodIebbbb+w= X-Google-Smtp-Source: AG47ELvI/VE91UymKPP0eXjMnufdMEZVLtB4uP081Mkj7twKThHHNSpfaejinz+3LlgRS+SQiR2jpXVvdVWo8JllCCU= X-Received: by 10.202.71.211 with SMTP id u202mr6070389oia.227.1519617305809; Sun, 25 Feb 2018 19:55:05 -0800 (PST) In-Reply-To: <87po4t9mxt.fsf@mid.deneb.enyo.de> Xref: news.gmane.org gmane.comp.lib.glibc.alpha:82903 Archived-At: Received: from server1.sourceware.org ([209.132.180.131] helo=sourceware.org) by blaine.gmane.org with esmtp (Exim 4.84_2) (envelope-from ) id 1eq9qd-0004S7-AM for glibc-alpha@blaine.gmane.org; Mon, 26 Feb 2018 04:53:07 +0100 Received: (qmail 15438 invoked by alias); 26 Feb 2018 03:55:10 -0000 Received: (qmail 15422 invoked by uid 89); 26 Feb 2018 03:55:09 -0000 On Sun, Feb 25, 2018 at 6:13 AM, Florian Weimer wrote: > * H. J. Lu: > >> On Sun, Feb 25, 2018 at 5:49 AM, Florian Weimer wrote: >>> * H. J. Lu: >>> >>>> On Sun, Feb 25, 2018 at 5:31 AM, Florian Weimer wrote: >>>>> * H. J. Lu: >>>>> >>>>>> libpthread cancellation implementation passes cancel_jmp_buf to >>>>>> libgcc unwinder, >>>>> >>>>> Oh. Where does it do that? If you mean _Unwind_ForcedUnwind, I think >>>>> that's just an opaque closure argument for the callback. >>>> >>>> Yes. Libgcc unwinder needs to deal with it. >>> >>> Please point me to the code. Thanks. >> >> sysdeps/nptl/unwind-forcedunwind.c has >> >> _Unwind_Reason_Code >> _Unwind_ForcedUnwind (struct _Unwind_Exception *exc, _Unwind_Stop_Fn stop, >> void *stop_argument) >> { >> if (__glibc_unlikely (libgcc_s_handle == NULL)) >> pthread_cancel_init (); >> else >> atomic_read_barrier (); >> >> _Unwind_Reason_Code (*forcedunwind) >> (struct _Unwind_Exception *, _Unwind_Stop_Fn, void *) >> = libgcc_s_forcedunwind; >> PTR_DEMANGLE (forcedunwind); >> return forcedunwind (exc, stop, stop_argument); >> } > > Thanks. I think stop_argument ends up in the private_2 member inside > unwind.inc, which is only passed back to the callback (the stop > function pointer) in _Unwind_ForcedUnwind_Phase2, and not interpreted > by libgcc itself. So this shouldn't be a problem. Please take a look at hjl/setjmp/cancel branch: https://github.com/hjl-tools/glibc/tree/hjl/setjmp/cancel Functions, like LIBC_START_MAIN, START_THREAD_DEFN as well as these with thread cancellation, call setjmp, but never return to their callers after longjmp returns. This patch adds and to provide a version of setjmp family functions, __setjmp_cancel and __sigsetjmp_cancel, which are used to implement thread cancellation. The default __setjmp_cancel and __sigsetjmp_cancel are defined as setjmp and __sigsetjmp, respectively, which are the same as before. On x86, a different version is added to avoid saving and restoring shadow stack register. __libc_longjmp, which is a private interface for cancellation implementation in libpthread, is changed to call __longjmp_cancel instead of __longjmp. This leaves cancel_jmp_buf unchanged. But is it worth it? 1. I have to add __setjmp_cancel and __sigsetjmp_cancel which won't save and restore shadow stack register. 2. I still need yet to add the new version of __sigsetjmp for older binaries. 3, Older .o files compiled against glibc 2.27 are still incompatible with glibc 2.28. -- H.J.