Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/lib/libexecinfo If Unwind_Backtrace is broken, ctx.n will st...



details:   https://anonhg.NetBSD.org/src/rev/bd9a6c6fecf3
branches:  trunk
changeset: 936407:bd9a6c6fecf3
user:      christos <christos%NetBSD.org@localhost>
date:      Sun Jul 26 15:53:05 2020 +0000

description:
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

diffstat:

 lib/libexecinfo/unwind.c |  6 ++++--
 1 files changed, 4 insertions(+), 2 deletions(-)

diffs (20 lines):

diff -r e31f98c3975a -r bd9a6c6fecf3 lib/libexecinfo/unwind.c
--- a/lib/libexecinfo/unwind.c  Sun Jul 26 15:53:01 2020 +0000
+++ b/lib/libexecinfo/unwind.c  Sun Jul 26 15:53:05 2020 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: unwind.c,v 1.4 2020/01/22 16:07:40 mgorny Exp $        */
+/*     $NetBSD: unwind.c,v 1.5 2020/07/26 15:53:05 christos Exp $      */
 
 /*-
  * Copyright (c) 2012 The NetBSD Foundation, Inc.
@@ -67,7 +67,9 @@
        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;



Home | Main Index | Thread Index | Old Index