From owner-svn-src-all@freebsd.org Mon Sep 21 16:43:39 2020 Return-Path: Delivered-To: svn-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 7884C3F5CDC; Mon, 21 Sep 2020 16:43:39 +0000 (UTC) (envelope-from phk@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4Bw9Hb2ZjKz4TS1; Mon, 21 Sep 2020 16:43:39 +0000 (UTC) (envelope-from phk@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 3BD1511565; Mon, 21 Sep 2020 16:43:39 +0000 (UTC) (envelope-from phk@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id 08LGhd9p041094; Mon, 21 Sep 2020 16:43:39 GMT (envelope-from phk@FreeBSD.org) Received: (from phk@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id 08LGhdrC041093; Mon, 21 Sep 2020 16:43:39 GMT (envelope-from phk@FreeBSD.org) Message-Id: <202009211643.08LGhdrC041093@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: phk set sender to phk@FreeBSD.org using -f From: Poul-Henning Kamp Date: Mon, 21 Sep 2020 16:43:39 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r365952 - head/contrib/libexecinfo X-SVN-Group: head X-SVN-Commit-Author: phk X-SVN-Commit-Paths: head/contrib/libexecinfo X-SVN-Commit-Revision: 365952 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.33 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 21 Sep 2020 16:43:39 -0000 Author: phk Date: Mon Sep 21 16:43:38 2020 New Revision: 365952 URL: https://svnweb.freebsd.org/changeset/base/365952 Log: Pull in fix from upstream NetBSD rev. 1.5: If Unwind_Backtrace is broken, ctx.n will still contain ~0, and we will return that which poor behavior for the user, so return 0 instead. We could document ~0 to be an error, but that would deviate from the Linux behavior which is not desirable. Noted by Poul-Henning Kamp PR: 209842 Modified: head/contrib/libexecinfo/unwind.c Modified: head/contrib/libexecinfo/unwind.c ============================================================================== --- head/contrib/libexecinfo/unwind.c Mon Sep 21 15:53:41 2020 (r365951) +++ head/contrib/libexecinfo/unwind.c Mon Sep 21 16:43:38 2020 (r365952) @@ -67,7 +67,9 @@ backtrace(void **arr, size_t len) ctx.n = (size_t)~0; _Unwind_Backtrace(tracer, &ctx); - if (ctx.n != (size_t)~0 && ctx.n > 0) + if (ctx.n == (size_t)~0) + ctx.n = 0; + else if (ctx.n > 0) ctx.arr[--ctx.n] = NULL; /* Skip frame below __start */ return ctx.n;