Project

General

Profile

Bug #4159

dtrace ignores all ustack helper frames from dead processes

Added by David Pacheco about 6 years ago. Updated over 5 years ago.

Status:
Resolved
Priority:
Normal
Assignee:
-
Category:
-
Start date:
2013-09-26
Due date:
% Done:

0%

Estimated time:
Difficulty:
Medium
Tags:
needs-triage

Description

Several users have reported issues tracing short-lived Node processes using the ustack helper. In particular, the ustack helper appears not to work, leaving function names unresolved, as described at http://www.listbox.com/member/archive/184261/2013/09/sort/time_rev/page/1/entry/6:32/20130924123850:C8272C98-2537-11E3-B834-9E61FA888C7E/

History

#1

Updated by David Pacheco about 6 years ago

I believe the problem is this logic in dt_print_ustack:

1080                 } else if (str != NULL && str[0] != '\\0' && str[0] != '@' &&
1081                     (P == NULL || (map = Paddr_to_map(P, pc[i])) == NULL ||
1082                     map->pr_mflags & MA_WRITE)) {
1083                         /*
1084                          * If the current string pointer in the string table
1085                          * does not point to an empty string _and_ the program
1086                          * counter falls in a writable region, we'll use the
1087                          * string from the string table instead of the raw
1088                          * address.  This last condition is necessary because
1089                          * some (broken) ustack helpers will return a string
1090                          * even for a program counter that they can't
1091                          * identify.  If we have a string for a program
1092                          * counter that falls in a segment that isn't
1093                          * writable, we assume that we have fallen into this
1094                          * case and we refuse to use the string.  Finally,
1095                          * note that if we could not grab the process (e.g.,
1096                          * because it exited), the information from the helper
1097                          * is better than nothing.
1098                          */
1099                         (void) snprintf(c, sizeof (c), "%s", str);

This was obviously added to fix a broken ustack helper, but it has the side effect that if we failed to grab the process for any reason (e.g., because it has exited), we ignore the ustack helper.

This diff may work, but I haven't even had a chance to test it yet:

diff --git a/usr/src/lib/libdtrace/common/dt_consume.c b/usr/src/lib/libdtrace/common/dt_consume.c
index b1e8d2d..d33a8c9 100644
--- a/usr/src/lib/libdtrace/common/dt_consume.c
+++ b/usr/src/lib/libdtrace/common/dt_consume.c
@@ -1078,8 +1078,8 @@ dt_print_ustack(dtrace_hdl_t *dtp, FILE *fp, const char *format,
                     "%s`%s", dt_basename(objname), name);
             }
         } else if (str != NULL && str[0] != '\\0' && str[0] != '@' &&
-            (P != NULL && ((map = Paddr_to_map(P, pc[i])) == NULL ||
-            (map->pr_mflags & MA_WRITE)))) {
+            (P == NULL || (map = Paddr_to_map(P, pc[i])) == NULL ||
+            map->pr_mflags & MA_WRITE)) {
             /*
              * If the current string pointer in the string table
              * does not point to an empty string _and_ the program
@@ -1091,7 +1091,10 @@ dt_print_ustack(dtrace_hdl_t *dtp, FILE *fp, const char *format,
              * identify.  If we have a string for a program
              * counter that falls in a segment that isn't
              * writable, we assume that we have fallen into this
-             * case and we refuse to use the string.
+             * case and we refuse to use the string.  Finally,
+             * note that if we could not grab the process (e.g.,
+             * because it exited), the information from the helper
+             * is better than nothing.
              */
             (void) snprintf(c, sizeof (c), "%s", str);
         } else {
#3

Updated by Rich Lowe over 5 years ago

  • Status changed from New to Resolved
#4

Updated by Electric Monk over 5 years ago

git commit aea650180b31dd5423d26fc0e8ae6b3a4dc50137

Author: Dave Pacheco <dap@joyent.com>

4159 dtrace ignores all ustack helper frames from dead processes
Reviewed by: Bryan Cantrill <bryan@joyent.com>
Reviewed by: Robert Mustacchi <rm@joyent.com>
Approved by: Gordon Ross <gwr@nexenta.com>

Also available in: Atom PDF