From patchwork Thu Jul 18 00:05:01 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ian Lance Taylor X-Patchwork-Id: 1961818 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=golang-org.20230601.gappssmtp.com header.i=@golang-org.20230601.gappssmtp.com header.a=rsa-sha256 header.s=20230601 header.b=zqDS373j; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=gcc.gnu.org (client-ip=2620:52:3:1:0:246e:9693:128c; helo=server2.sourceware.org; envelope-from=gcc-patches-bounces~incoming=patchwork.ozlabs.org@gcc.gnu.org; receiver=patchwork.ozlabs.org) Received: from server2.sourceware.org (server2.sourceware.org [IPv6:2620:52:3:1:0:246e:9693:128c]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (secp384r1) server-digest SHA384) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4WPY3l4HPvz1yY1 for ; Thu, 18 Jul 2024 10:05:39 +1000 (AEST) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 5D407385E458 for ; Thu, 18 Jul 2024 00:05:37 +0000 (GMT) X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from mail-yw1-x1132.google.com (mail-yw1-x1132.google.com [IPv6:2607:f8b0:4864:20::1132]) by sourceware.org (Postfix) with ESMTPS id 98853385841D for ; Thu, 18 Jul 2024 00:05:15 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 98853385841D Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=golang.org Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=golang.org ARC-Filter: OpenARC Filter v1.0.0 sourceware.org 98853385841D Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=2607:f8b0:4864:20::1132 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1721261117; cv=none; b=SsNDNOlMM+ASOMdPG3wnut5OdS5prom+yYOyb2U3d1AIwquhleqKCddoKF3qBlRVysYW5e/H7kLWJ/6C8QvV9GYTH6fXMS0lFYSdYbuFtDUsx1hm8Wj63mm7CDO58tJoaeaMImrWIxXy1m4XNTrDie1gbV9qKttT7eOBfjUUd8g= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1721261117; c=relaxed/simple; bh=DUMK3JsiS/stiFIXmsn8h4aIwDbssbu49yzgTjDHiig=; h=DKIM-Signature:MIME-Version:From:Date:Message-ID:Subject:To; b=JSgoPLlS0wIrPXaO3UlF/oMf+GsMeOHm598n8x3dkoThUbqU3oSLKZECuJrdOsPQ9mie693k+hR3qHRYLM7WaUzDMDIzdbQgJYG3MKQOh6DA9yF8GuuZVnxwS/78p3wlzm3SdMcw6eee7Srqf8rmIt7hERsyCE8/mRyiAQXqgo4= ARC-Authentication-Results: i=1; server2.sourceware.org Received: by mail-yw1-x1132.google.com with SMTP id 00721157ae682-64f4fd64773so2404107b3.0 for ; Wed, 17 Jul 2024 17:05:15 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=golang-org.20230601.gappssmtp.com; s=20230601; t=1721261114; x=1721865914; darn=gcc.gnu.org; h=to:subject:message-id:date:from:mime-version:from:to:cc:subject :date:message-id:reply-to; bh=rnEb6cBc3A3iqtI5o+h/YsBW7bAix4MK6Fdi9i9tTfE=; b=zqDS373jU5g/X6okLEEGtOLYFkzyaWeh0KhEBxwXCNcIxoTm8LZ1gdn/fwXb/2AznN KKAO7EHxm2aqYOSeN5hevRrKMezb4v6YrmvfepHHIIEvRCZ3M4maYuihnx7eKVIn3V9q AS+lGEfSvyTd1p//RV+zBc43QPIomE8AFzZr8jGm7f0NlV4DDqfIL1CPm3YlQ77g1rvl 7IXaZ8SE+E9dyXPvGnWE6ffbB5hOPlzJRiIz/mTBQck0JbUHuNLJkIkc9uwNC/PKNK7A DBXCAuzEiRT3PmBZZz/SY16QkrSk+lI1pB+O0KRmma/ejsP86Yn7fMOlI3bCkqB4ud1+ 6+Dw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1721261114; x=1721865914; h=to:subject:message-id:date:from:mime-version:x-gm-message-state :from:to:cc:subject:date:message-id:reply-to; bh=rnEb6cBc3A3iqtI5o+h/YsBW7bAix4MK6Fdi9i9tTfE=; b=qcxExCssh8jYzMTkLYo2LWoWSJJexkQP+tP00TwSb1YkzkzkDbKnidJJEI0xfEcLK7 3X8eJ0jS7zYQNQlSSd0lHKjy9hwQotGJ7GLh2dLuZfcI4MsGPZeHDXxP40BfkhW1UZoe 47sFwX2IhYq1zI/KLXnGxIFs1VmZTOyH7C6lVHvcSp9qR8SpXh4BiNvvWZa3TGElaOKW DtJFQZpRaekx0Z3zWWW4WVXZStMYu0tvJ7PyVKS9lnIBMGFayE/pQo5TCdTXWNxrgr8w WcX1ZnGbFA5sFWy/5dMAZzv0VUeK1iJ79lXI8ihakyDZIIQlIBiC4VwlQbdwX8gQwGIg NeIA== X-Gm-Message-State: AOJu0YykZYBhqIST89er9H159pEpAeb/ZZ8ODF3shQJ5f8sQVXn8oXD4 QzTxMoe/8BC/GdM2fggNenvEQM/LAj2bdbdNV8/34bdqyNHCYr9GQgXi5drv7gT4bWpKBJcodKk YerYDsIs5LxOXP6jKbqJaTPDoVlI646oYNWGINDDxZc19mn7MJTM= X-Google-Smtp-Source: AGHT+IHRC3ivdvkZPeplaH4KH+KJp7FJE4xb4rJq4vOKej8q2ADVFEvBZZvtn3QchojFkoq0oNdskjyuHmJADoAcy9g= X-Received: by 2002:a05:690c:318b:b0:650:a40c:acb1 with SMTP id 00721157ae682-66605250be6mr12855367b3.28.1721261114483; Wed, 17 Jul 2024 17:05:14 -0700 (PDT) MIME-Version: 1.0 From: Ian Lance Taylor Date: Wed, 17 Jul 2024 17:05:01 -0700 Message-ID: Subject: libbacktrace patch committed: Mention dl_iterate_phdr in README To: gcc-patches X-Spam-Status: No, score=-9.4 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, GIT_PATCH_0, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org X-BeenThere: gcc-patches@gcc.gnu.org X-Mailman-Version: 2.1.30 Precedence: list List-Id: Gcc-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: gcc-patches-bounces~incoming=patchwork.ozlabs.org@gcc.gnu.org This patch adds some notes about dl_iterate_phdr to the libbacktrace README file. In general dl_iterate_phdr is not async-signal-safe and does call malloc, so programs that want to use libbacktrace functions from a signal handler or within malloc must make an initiali libbacktrace call in order to call dl_iterate_phdr. Committed to mainline. Ian * README: Add notes about dl_iterate_phdr. 14667f4cc51b6c59cf9e6c05f3bcac17df94ef10 diff --git a/libbacktrace/README b/libbacktrace/README index 6225f92b855..6e6ec332fe2 100644 --- a/libbacktrace/README +++ b/libbacktrace/README @@ -5,8 +5,18 @@ The libbacktrace library may be linked into a program or library and used to produce symbolic backtraces. Sample uses would be to print a detailed backtrace when an error occurs or to gather detailed profiling information. + In general the functions provided by this library are async-signal-safe, meaning that they may be safely called from a signal handler. +That said, on systems that use dl_iterate_phdr, such as GNU/Linux, +the first call to a libbacktrace function will call dl_iterate_phdr, +which is not in general async-signal-safe. Therefore, programs +that call libbacktrace from a signal handler should ensure that they +make an initial call from outside of a signal handler. +Similar considerations apply when arranging to call libbacktrace +from within malloc; dl_iterate_phdr can also call malloc, +so make an initial call to a libbacktrace function outside of +malloc before trying to call libbacktrace functions within malloc. The libbacktrace library is provided under a BSD license. See the source files for the exact license text. @@ -20,7 +30,7 @@ will work. See the source file backtrace-supported.h.in for the macros that it defines. -As of October 2020, libbacktrace supports ELF, PE/COFF, Mach-O, and +As of July 2024, libbacktrace supports ELF, PE/COFF, Mach-O, and XCOFF executables with DWARF debugging information. In other words, it supports GNU/Linux, *BSD, macOS, Windows, and AIX. The library is written to make it straightforward to add support for