Module Name:    src
Committed By:   dholland
Date:           Sun Jul 31 19:10:54 UTC 2016

Modified Files:
        src/sys/arch/ia64/ia64: db_trace.c
        src/sys/arch/ia64/unwind: stackframe.c

Log Message:
Don't check for unsigned variables being less than 0 in
patchunwindframe(). Instead, check before subtracting, which in this
case means at the call site.

It would probably be better to change the call signature so the
subtraction happens inside patchunwindframe(), but since I don't
really know exactly what this code is trying to do I'm not comfortable
changing it.

Issue 1 in PR 51297 from David Binderman.


To generate a diff of this commit:
cvs rdiff -u -r1.4 -r1.5 src/sys/arch/ia64/ia64/db_trace.c
cvs rdiff -u -r1.5 -r1.6 src/sys/arch/ia64/unwind/stackframe.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/arch/ia64/ia64/db_trace.c
diff -u src/sys/arch/ia64/ia64/db_trace.c:1.4 src/sys/arch/ia64/ia64/db_trace.c:1.5
--- src/sys/arch/ia64/ia64/db_trace.c:1.4	Mon Apr 28 20:23:25 2008
+++ src/sys/arch/ia64/ia64/db_trace.c	Sun Jul 31 19:10:54 2016
@@ -1,4 +1,4 @@
-/*	$NetBSD: db_trace.c,v 1.4 2008/04/28 20:23:25 martin Exp $	*/
+/*	$NetBSD: db_trace.c,v 1.5 2016/07/31 19:10:54 dholland Exp $	*/
 
 /* Inspired by reading alpha/db_trace.c */
 
@@ -99,6 +99,7 @@ db_stack_trace_print(db_expr_t addr, boo
 		struct unwind_frame *uwf = &current_frame;
 		debug_frame_dump_XXX(uwf);
 #endif
+		KASSERT(ip >= kernstart);
 		patchunwindframe(&current_frame, ip - kernstart, kernstart);
 #ifdef UNWIND_DIAGNOSTIC
 		debug_frame_dump_XXX(uwf);
@@ -186,6 +187,7 @@ rewindframe(struct unwind_frame *uwf, db
 
 	/* Stomp on rp and pfs 
 	 */
+	KASSERT(ip >= kernstart);
 	patchunwindframe(uwf, ip - kernstart, kernstart);
 
 #ifdef UNWIND_DIAGNOSTIC

Index: src/sys/arch/ia64/unwind/stackframe.c
diff -u src/sys/arch/ia64/unwind/stackframe.c:1.5 src/sys/arch/ia64/unwind/stackframe.c:1.6
--- src/sys/arch/ia64/unwind/stackframe.c:1.5	Mon Mar 10 13:47:16 2014
+++ src/sys/arch/ia64/unwind/stackframe.c	Sun Jul 31 19:10:54 2016
@@ -1,4 +1,4 @@
-/*	$NetBSD: stackframe.c,v 1.5 2014/03/10 13:47:16 martin Exp $	*/
+/*	$NetBSD: stackframe.c,v 1.6 2016/07/31 19:10:54 dholland Exp $	*/
 
 /* Contributed to the NetBSD foundation by Cherry G. Mathew <[email protected]>
  * This file contains routines to use decoded unwind descriptor entries
@@ -1169,10 +1169,12 @@ patchunwindframe(struct unwind_frame *uw
 	struct uwtable_ent *uwt;
 	uint64_t infoptr, procoffset, slotoffset;
 
+#if 0 /* does not work - moved to assertion at the call site */
 	if (iprel < 0) {
 		panic("unwind ip out of range!!! \n");
 		return;
 	}
+#endif
 
 
 	uwt = get_unwind_table_entry(iprel);

Reply via email to