[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[monit-dev] [monit] r286 committed - Fix crash on MacOSX during process
From: |
monit |
Subject: |
[monit-dev] [monit] r286 committed - Fix crash on MacOSX during process tree initialization:... |
Date: |
Sun, 26 Sep 2010 17:37:27 +0000 |
Revision: 286
Author: martin2812
Date: Sun Sep 26 10:36:30 2010
Log: Fix crash on MacOSX during process tree initialization:
Thread 0 Crashed: Dispatch queue: com.apple.main-thread
0 monit 0x00000001000367ec skipString + 35
(sysdep_DARWIN.c:367)
1 monit 0x0000000100035d95
initprocesstree_sysdep + 968 (sysdep_DARWIN.c:226)
2 monit 0x000000010000eacb initprocesstree
+ 79 (process.c:221)
3 monit 0x000000010001d17b validate + 75
(validate.c:162)
4 monit 0x000000010000c2d0 do_default + 723
(monitor.c:545)
5 monit 0x000000010000bb1b do_action + 119
(monitor.c:394)
6 monit 0x000000010000b552 main + 98
(monitor.c:160)
7 monit 0x00000001000012ec start + 52
http://code.google.com/p/monit/source/detail?r=286
Modified:
/trunk/CHANGES.txt
/trunk/process/sysdep_DARWIN.c
=======================================
--- /trunk/CHANGES.txt Sat Sep 25 10:35:23 2010
+++ /trunk/CHANGES.txt Sun Sep 26 10:36:30 2010
@@ -9,6 +9,9 @@
Version 5.3
+BUGFIXES:
+
+* Fix crash on MacOSX
Version 5.2.1
=======================================
--- /trunk/process/sysdep_DARWIN.c Sun May 2 12:57:05 2010
+++ /trunk/process/sysdep_DARWIN.c Sun Sep 26 10:36:30 2010
@@ -97,9 +97,6 @@
static long cpu_syst_old = 0;
-static char *skipString(char *p);
-
-
/* ------------------------------------------------------------------
Public */
@@ -190,7 +187,7 @@
LogError("system statistic error -- sysctl failed: %s\n", STRERROR);
return FALSE;
}
- args = (char *)xcalloc(1, args_size);
+ args = (char *)xcalloc(1, args_size + 1);
size = args_size; // save for per-process sysctl loop
for (i = 0; i < treesize; i++) {
@@ -214,18 +211,22 @@
* }
* The strings are terminated with '\0' and may have variable '\0'
padding
*/
- int argc = *args;
- char *p = args + sizeof(int); // arguments beginning
+ int argc = *args;
+ char *p = args + sizeof(int); // arguments beginning
Buffer_T cmdline;
memset(&cmdline, 0, sizeof(Buffer_T));
- p = skipString(p); // skip exec name
- while (argc-- && p < args + args_size) {
- Util_stringbuffer(&cmdline, argc ? "%s " : "%s", p);
- p = skipString(p);
- }
- pt[i].cmdline = cmdline.buf;
+ p += strlen(p); // skip exename
+ while (argc && p < args + args_size) {
+ if (*p == 0) { // skip terminating 0 and variable length 0 padding
+ p++;
+ continue;
+ }
+ Util_stringbuffer(&cmdline, argc-- ? "%s " : "%s", p);
+ p += strlen(p);
+ }
+ pt[i].cmdline = Util_trim(cmdline.buf);
}
if (! pt[i].cmdline || ! *pt[i].cmdline)
pt[i].cmdline = xstrdup(pinfo[i].kp_proc.p_comm);
@@ -361,11 +362,3 @@
return FALSE;
}
-
-static char *skipString(char *p) {
- p += strlen(p);
- while (! *p) // skip terminating '\0' and possible padding
- p++;
- return p;
-}
-
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [monit-dev] [monit] r286 committed - Fix crash on MacOSX during process tree initialization:...,
monit <=