Skip to contentSkip to conversation

debugobjects: Make stack check warning more informative

RFC PATCH In review Joel Fernandes 4 participants 4 messages Jul 23, 2018 – Jul 30, 2018

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

RFC PATCH 1/1 debugobjects: Make stack check warning more informative

From: "Joel Fernandes (Google)" <[email protected]>

Recently we debugged an issue where debugobject tracking was telling us of an annotation issue. Turns out the issue was due to the object in concern being on a different stack which was due to another issue.

Discussing with tglx, he suggested printing the pointers and the location of the stack for the currently running task. This helped find the object was on the wrong stack. I turned the resulting patch into something upstreamable, so that the error message is more informative and can help in debugging for similar issues in the future.

---
 lib/debugobjects.c | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)
lib/debugobjects.c +5 -2
index 994be4805cec..24c1df0d7466 100644
@@ -360,9 +360,12 @@ static void debug_object_is_on_stack(void *addr, int onstack)
 
 	limit++;
 	if (is_on_stack)
-		pr_warn("object is on stack, but not annotated\n");
+		pr_warn("object %p is on stack %p, but NOT annotated.\n", addr,
+			 task_stack_page(current));
 	else
-		pr_warn("object is not on stack, but annotated\n");
+		pr_warn("object %p is NOT on stack %p, but annotated.\n", addr,
+			 task_stack_page(current));
+
 	WARN_ON(1);
 }
 
Signature · 1 line
2.18.0.233.g985f88cf7e-goog
Acked-by on v1 1/1
#1 lore raw
Quoted 11 lines · Joel Fernandes

From: "Joel Fernandes (Google)" <[email protected]>

Recently we debugged an issue where debugobject tracking was telling us of an annotation issue. Turns out the issue was due to the object in concern being on a different stack which was due to another issue.

Discussing with tglx, he suggested printing the pointers and the location of the stack for the currently running task. This helped find the object was on the wrong stack. I turned the resulting patch into something upstreamable, so that the error message is more informative and can help in debugging for similar issues in the future.

Quoted 25 lines
---
  lib/debugobjects.c | 7 +++++--
  1 file changed, 5 insertions(+), 2 deletions(-)
lib/debugobjects.c +5 -2
index 994be4805cec..24c1df0d7466 100644
@@ -360,9 +360,12 @@ static void debug_object_is_on_stack(void *addr, int onstack)
 
  	limit++;
  	if (is_on_stack)
-		pr_warn("object is on stack, but not annotated\n");
+		pr_warn("object %p is on stack %p, but NOT annotated.\n", addr,
+			 task_stack_page(current));
  	else
-		pr_warn("object is not on stack, but annotated\n");
+		pr_warn("object %p is NOT on stack %p, but annotated.\n", addr,
+			 task_stack_page(current));
+
  	WARN_ON(1);
  }
 
Acked-by on v1 1/1
#2 lore raw
In reply to Joel Fernandes
Quoted 26 lines · Joel Fernandes

From: "Joel Fernandes (Google)" <[email protected]>

Recently we debugged an issue where debugobject tracking was telling us of an annotation issue. Turns out the issue was due to the object in concern being on a different stack which was due to another issue.

Discussing with tglx, he suggested printing the pointers and the location of the stack for the currently running task. This helped find the object was on the wrong stack. I turned the resulting patch into something upstreamable, so that the error message is more informative and can help in debugging for similar issues in the future.

---
 lib/debugobjects.c | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)
lib/debugobjects.c +0 -1
index 994be4805cec..24c1df0d7466 100644
@@ -360,9 +360,12 @@ static void debug_object_is_on_stack(void *addr, int onstack)
 
 	limit++;
 	if (is_on_stack)
-		pr_warn("object is on stack, but not annotated\n");

lib/debugobjects.c static void debug_object_is_on_stack(void *addr, int onstack) · line 371

Quoted 10 lines
lib/debugobjects.c +5 -1
+		pr_warn("object %p is on stack %p, but NOT annotated.\n", addr,
+			 task_stack_page(current));
 	else
-		pr_warn("object is not on stack, but annotated\n");
+		pr_warn("object %p is NOT on stack %p, but annotated.\n", addr,
+			 task_stack_page(current));
+
 	WARN_ON(1);
 }
 
#3 lore raw
In reply to Joel Fernandes
debugobjects: Make stack check warning more informative
Commit-ID:  fc91a3c4c27acdca0bc13af6fbb68c35cfd519f2
Gitweb:     https://git.kernel.org/tip/fc91a3c4c27acdca0bc13af6fbb68c35cfd519f2
Author:     Joel Fernandes (Google) <[email protected]>
AuthorDate: Mon, 23 Jul 2018 14:25:31 -0700
Committer:  Thomas Gleixner <[email protected]>
CommitDate: Mon, 30 Jul 2018 21:36:37 +0200

debugobjects: Make stack check warning more informative

While debugging an issue debugobject tracking warned about an annotation issue of an object on stack. It turned out that the issue was due to the object in concern being on a different stack which was due to another issue.

Thomas suggested to print the pointers and the location of the stack for the currently running task. This helped to figure out that the object was on the wrong stack.

As this is general useful information for debugging similar issues, make the error message more informative by printing the pointers.

[ tglx: Massaged changelog ]

---
 lib/debugobjects.c | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)
lib/debugobjects.c +5 -2
index 994be4805cec..24c1df0d7466 100644
@@ -360,9 +360,12 @@ static void debug_object_is_on_stack(void *addr, int onstack)
 
 	limit++;
 	if (is_on_stack)
-		pr_warn("object is on stack, but not annotated\n");
+		pr_warn("object %p is on stack %p, but NOT annotated.\n", addr,
+			 task_stack_page(current));
 	else
-		pr_warn("object is not on stack, but annotated\n");
+		pr_warn("object %p is NOT on stack %p, but annotated.\n", addr,
+			 task_stack_page(current));
+
 	WARN_ON(1);
 }