From patchwork Sat Mar 3 09:10:18 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Aurelien Jarno X-Patchwork-Id: 881012 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=sourceware.org (client-ip=209.132.180.131; helo=sourceware.org; envelope-from=libc-alpha-return-90753-incoming=patchwork.ozlabs.org@sourceware.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=aurel32.net Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; secure) header.d=sourceware.org header.i=@sourceware.org header.b="OCiXDMdy"; dkim-atps=neutral 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 ozlabs.org (Postfix) with ESMTPS id 3ztgPY32Wbz9s8f for ; Sat, 3 Mar 2018 20:10:40 +1100 (AEDT) DomainKey-Signature: a=rsa-sha1; c=nofws; d=sourceware.org; h=list-id :list-unsubscribe:list-subscribe:list-archive:list-post :list-help:sender:from:to:cc:subject:date:message-id; q=dns; s= default; b=X6E0qzNB5ZNM9KFffJx/HSP7LrMAYlb23QPORnVjLZdkB5lVoykGV mfYUYBtlFl0ufn8Qmrzjy1nF99KSd/L5gEiTmij+JjOISr1+sl1AHVWs8gVrfLSW bCM8cRQsKHjYVPIYYlDo334WmbVDYuJmIBQZOVPQSjTI1T/0RL75qU= 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:from:to:cc:subject:date:message-id; s=default; bh=+ilxv0FVcoznGDCMGIy7p/Ff6F8=; b=OCiXDMdydjOepT3ZvD0PIzC3Ajzm /6zZAfMPJaMW1iJoJqjzGjOhiJE6Cp8fQDSQ29xL5jVGVyWOQo2M0rRkU6Xm9T31 FwbrO6dd9+cA+smT06al9TgQF5XDLBIcyIEGPClYMr5aZ45ukS397jF9NAoG3rf3 pIDuKAUulEb6NDg= Received: (qmail 42600 invoked by alias); 3 Mar 2018 09:10:35 -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 Delivered-To: mailing list libc-alpha@sourceware.org Received: (qmail 42581 invoked by uid 89); 3 Mar 2018 09:10:34 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-25.9 required=5.0 tests=BAYES_00, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, KAM_LAZY_DOMAIN_SECURITY, T_RP_MATCHES_RCVD autolearn=ham version=3.3.2 spammy=Hx-languages-length:2278 X-HELO: hall.aurel32.net From: Aurelien Jarno To: libc-alpha@sourceware.org Cc: Aurelien Jarno Subject: [PATCH] sparc32: Add nop before __startcontext to stop unwinding [BZ #xxxxx] Date: Sat, 3 Mar 2018 10:10:18 +0100 Message-Id: <20180303091018.32019-1-aurelien@aurel32.net> On sparc32 tst-makecontext fails, as backtrace called within a context created by makecontext to yield infinite backtrace. Fix that the same way than nios2 by adding a nop just before __startcontext. This is needed as otherwise FDE lookup just repeatedly finds __setcontext's FDE in an infinite loop, due to the convention of using 'address - 1' for FDE lookup. Changelog: [BZ #22919] * sysdeps/unix/sysv/linux/sparc/sparc32/setcontext.S (__startcontext): Add nop before __startcontext, add explaining comments. --- ChangeLog | 6 ++++++ sysdeps/unix/sysv/linux/sparc/sparc32/setcontext.S | 13 +++++++++++++ 2 files changed, 19 insertions(+) diff --git a/ChangeLog b/ChangeLog index 4b7e0a0261..6216817498 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,9 @@ +2018-03-03 Aurelien Jarno + + [BZ #22919] + * sysdeps/unix/sysv/linux/sparc/sparc32/setcontext.S (__startcontext): + Add nop before __startcontext, add explaining comments. + 2018-03-01 Maciej W. Rozycki * nptl_db/td_ta_thr_iter.c (iterate_thread_list): Remove diff --git a/sysdeps/unix/sysv/linux/sparc/sparc32/setcontext.S b/sysdeps/unix/sysv/linux/sparc/sparc32/setcontext.S index 695f172c63..283aef1b30 100644 --- a/sysdeps/unix/sysv/linux/sparc/sparc32/setcontext.S +++ b/sysdeps/unix/sysv/linux/sparc/sparc32/setcontext.S @@ -95,6 +95,19 @@ END(__setcontext) weak_alias (__setcontext, setcontext) +/* We add an NOP here to separate between __setcontext/__startcontext. The + wanted behavior that happens is: when unwinding from a function called + inside a makecontext() context, FDE lookup will use '&__startcontext - 1', + then returns NULL for no FDE found, and immediately ends the unwind, in + a normal fashion. + + If this NOP word does not exist, FDE lookup just repeatedly finds + __setcontext's FDE in an infinite loop, due to the convention of using + 'address - 1' for FDE lookup. Modifiying/deleting the below + __startcontext's FDE has no help on this. */ + + nop + /* This is the helper code which gets called if a function which is registered with 'makecontext' returns. In this case we have to install the context listed in the uc_link element of the context