public inbox for frysk-cvs@sourceware.org help / color / mirror / Atom feed
From: cagney@sourceware.org To: frysk-cvs@sourceware.org Subject: [SCM] master: Detect/log bad /proc/PID/task/TID entries. Date: Wed, 12 Mar 2008 00:26:00 -0000 [thread overview] Message-ID: <20080312002627.23971.qmail@sourceware.org> (raw) The branch, master has been updated via bac57ca6670cb2cfc1e02de0351288cf38e8a649 (commit) from 4abb4a8829293f641e08ec74c12dde3183c5f376 (commit) Those revisions listed above that are new to this repository have not appeared on any other notification email. - Log ----------------------------------------------------------------- commit bac57ca6670cb2cfc1e02de0351288cf38e8a649 Author: Andrew Cagney <cagney@redhat.com> Date: Tue Mar 11 20:25:34 2008 -0400 Detect/log bad /proc/PID/task/TID entries. frysk-sys/frysk/sys/proc/ChangeLog 2008-03-11 Andrew Cagney <cagney@redhat.com> * cni/ProcBuilder.cxx (ProcBuilder::scan): Add warnings when PID is bogus. * ProcBuilder.java (warning): Add. ----------------------------------------------------------------------- Summary of changes: frysk-sys/frysk/sys/proc/ChangeLog | 6 ++++++ frysk-sys/frysk/sys/proc/ProcBuilder.java | 8 ++++++-- frysk-sys/frysk/sys/proc/cni/ProcBuilder.cxx | 23 ++++++++++++++++++++--- 3 files changed, 32 insertions(+), 5 deletions(-) First 500 lines of diff: diff --git a/frysk-sys/frysk/sys/proc/ChangeLog b/frysk-sys/frysk/sys/proc/ChangeLog index 6713af1..39f22c8 100644 --- a/frysk-sys/frysk/sys/proc/ChangeLog +++ b/frysk-sys/frysk/sys/proc/ChangeLog @@ -1,3 +1,9 @@ +2008-03-11 Andrew Cagney <cagney@redhat.com> + + * cni/ProcBuilder.cxx (ProcBuilder::scan): Add warnings when PID + is bogus. + * ProcBuilder.java (warning): Add. + 2008-02-14 Andrew Cagney <cagney@redhat.com> * Stat.java (toString()): New. diff --git a/frysk-sys/frysk/sys/proc/ProcBuilder.java b/frysk-sys/frysk/sys/proc/ProcBuilder.java index 6e34267..9f107ce 100644 --- a/frysk-sys/frysk/sys/proc/ProcBuilder.java +++ b/frysk-sys/frysk/sys/proc/ProcBuilder.java @@ -41,6 +41,8 @@ package frysk.sys.proc; import gnu.gcj.RawData; import frysk.sys.ProcessIdentifier; +import frysk.rsl.Log; +import frysk.rsl.LogFactory; /** * Scan the <tt>/proc</tt>, or <tt>/proc/</tt>pid<tt>/task</tt> @@ -48,6 +50,8 @@ import frysk.sys.ProcessIdentifier; * encountered. */ public abstract class ProcBuilder { + private static final Log warning = LogFactory.warning(ProcBuilder.class); + /** * Iterate over the <tt>/proc</tt>pid<tt>/task</tt> directory * notifying ProcBuilder of each "interesting" entry. Use @@ -61,7 +65,7 @@ public abstract class ProcBuilder { if (dir == null) return false; try { - scan (dir); + scan(dir, pid, warning); } finally { close (dir); @@ -85,6 +89,6 @@ public abstract class ProcBuilder { * directory. Move to frysk.sys.Dir? */ private native RawData open(int pid); - private native void scan(RawData dir); + private native void scan(RawData dir, int pid, Log warning); private native void close(RawData dir); } diff --git a/frysk-sys/frysk/sys/proc/cni/ProcBuilder.cxx b/frysk-sys/frysk/sys/proc/cni/ProcBuilder.cxx index a58c495..8aa0fa9 100644 --- a/frysk-sys/frysk/sys/proc/cni/ProcBuilder.cxx +++ b/frysk-sys/frysk/sys/proc/cni/ProcBuilder.cxx @@ -49,6 +49,8 @@ #include "frysk/sys/proc/ProcBuilder.h" #include "frysk/sys/ProcessIdentifier.h" #include "frysk/sys/ProcessIdentifierFactory.h" +#include "frysk/rsl/Log.h" +#include "frysk/rsl/cni/Log.hxx" gnu::gcj::RawData* frysk::sys::proc::ProcBuilder::open (jint pid) @@ -68,9 +70,11 @@ frysk::sys::proc::ProcBuilder::open (jint pid) } void -frysk::sys::proc::ProcBuilder::scan (gnu::gcj::RawData* rawData) +frysk::sys::proc::ProcBuilder::scan(gnu::gcj::RawData* rawData, jint pid, + frysk::rsl::Log* warning) { DIR* proc = (DIR*) rawData; + int bad = 1; // something non-ve or 0. while (true) { @@ -79,14 +83,27 @@ frysk::sys::proc::ProcBuilder::scan (gnu::gcj::RawData* rawData) if (dirent == NULL) break; - // Get the pid, skip if non-numeric. + // Scan the pid, skip if non-numeric. char* end = NULL; int id = strtol (dirent->d_name, &end, 10); if (end == dirent->d_name) continue; - build(frysk::sys::ProcessIdentifierFactory::create(id)); + // Seems some kernels return a dirent containing bad (e.g., 0) or + // even random entries; report them and then throw an error. + if (bad <= 0) { + logf(warning, "/proc/%d/task contained bad pid: %d; skipping %d", + (int)pid, bad, id); + } else if (id <= 0) { + bad = id; + logf(warning, "/proc/%d/task contains bad pid: %d", (int)pid, id); + } else { + build(frysk::sys::ProcessIdentifierFactory::create(id)); + } } + + if (bad <= 0) + throwRuntimeException("/proc/$$/task contains bad pid", "pid", bad); } void hooks/post-receive -- frysk system monitor/debugger
reply other threads:[~2008-03-12 0:26 UTC|newest] Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions: You may reply publicly to this message via plain-text email using any one of the following methods: * Save the following mbox file, import it into your mail client, and reply-to-all from there: mbox Avoid top-posting and favor interleaved quoting: https://en.wikipedia.org/wiki/Posting_style#Interleaved_style * Reply using the --to, --cc, and --in-reply-to switches of git-send-email(1): git send-email \ --in-reply-to=20080312002627.23971.qmail@sourceware.org \ --to=cagney@sourceware.org \ --cc=frysk-cvs@sourceware.org \ --cc=frysk@sourceware.org \ /path/to/YOUR_REPLY https://kernel.org/pub/software/scm/git/docs/git-send-email.html * If your mail client supports setting the In-Reply-To header via mailto: links, try the mailto: linkBe sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox; as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).