Skip site navigation (1)Skip section navigation (2)
Date:      Mon, 21 Sep 2020 16:43:39 +0000 (UTC)
From:      Poul-Henning Kamp <phk@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org
Subject:   svn commit: r365952 - head/contrib/libexecinfo
Message-ID:  <202009211643.08LGhdrC041093@repo.freebsd.org>

next in thread | raw e-mail | index | archive | help
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;



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?202009211643.08LGhdrC041093>