delorie.com/archives/browse.cgi   search  
Mail Archives: cygwin/2006/06/12/13:20:59

X-Spam-Check-By: sourceware.org
From: "Dave Korn" <dave DOT korn AT artimi DOT com>
To: <cygwin AT cygwin DOT com>
Subject: pstree -a gives SEGV
Date: Mon, 12 Jun 2006 18:19:28 +0100
Message-ID: <024a01c68e44$5c3a6910$a501a8c0@CAM.ARTIMI.COM>
MIME-Version: 1.0
X-Mailer: Microsoft Office Outlook 11
Mailing-List: contact cygwin-help AT cygwin DOT com; run by ezmlm
List-Subscribe: <mailto:cygwin-subscribe AT cygwin DOT com>
List-Archive: <http://sourceware.org/ml/cygwin/>
List-Post: <mailto:cygwin AT cygwin DOT com>
List-Help: <mailto:cygwin-help AT cygwin DOT com>, <http://sourceware.org/ml/#faqs>
Sender: cygwin-owner AT cygwin DOT com
Mail-Followup-To: cygwin AT cygwin DOT com
Delivered-To: mailing list cygwin AT cygwin DOT com
Note-from-DJ: This may be spam

------=_NextPart_000_024B_01C68E4C.BDFED110
Content-Type: text/plain;
	charset="us-ascii"
Content-Transfer-Encoding: 7bit


    Hi all,

  Dunno about everyone else, but on my system "pstree -a" crashes with a SEGV
everytime.  On looking into it, it turns out to be because the process object
it creates for pid 1 (we don't have a real init process on cygwin) isn't fully
initialised (it works by lazy initialisation, creating the object for a given
pid when it first finds a reference to that pid as ppid of another process,
but it doesn't fill in the details until that pid is subsequently enumerated,
and we don't have a psuedo-entry in /proc/1, even though we use it as the ppid
of top-level cygwin processes, so the entry for pid 1 gets created but never
filled in and we crash when we try and print out its command line, since the
supposed argc is some uninitialised and generally huge/negative hex number).

  Anyway if anyone else wants "pstree -a" to work, I found the attached patch
solved the problem for me.  The first hunk fixes a minor build error, the
second ensures a sane default (i.e. empty) command line if there's no real
/proc entry for the pid.  You also may need to take care of config options and
adding -lintl, as described in the original announcement[*].

dk AT rainbow /artimi/chips/tulla> /usr/build/install/bin/cygcheck.exe -c psmisc
Cygwin Package Information
Package              Version        Status
psmisc               21.5-1         OK
dk AT rainbow /artimi/chips/tulla>

    cheers,
      DaveK

[*] - http://www.cygwin.com/ml/cygwin-announce/2005-03/msg00003.html
-- 
Can't think of a witty .sigline today....

------=_NextPart_000_024B_01C68E4C.BDFED110
Content-Type: application/octet-stream;
	name="pstree-segv-fix.diff"
Content-Transfer-Encoding: quoted-printable
Content-Disposition: attachment;
	filename="pstree-segv-fix.diff"

diff -pruN psmisc-21.5-1/src/pstree.c psmisc-21.5-1.new/src/pstree.c=0A=
--- psmisc-21.5-1/src/pstree.c	2005-03-03 20:00:04.001000000 +0000=0A=
+++ psmisc-21.5-1.new/src/pstree.c	2006-06-12 10:30:37.665928400 +0100=0A=
@@ -16,7 +16,9 @@=0A=
 #include <pwd.h>=0A=
 #include <dirent.h>=0A=
 #include <curses.h>=0A=
+#ifndef __CYGWIN__=0A=
 #include <term.h>=0A=
+#endif=0A=
 #include <termios.h>=0A=
 #ifdef __CYGWIN__=0A=
 #include <ncurses.h>=0A=
@@ -278,6 +280,8 @@ new_proc (const char *comm, pid_t pid, u=0A=
   new->pid =3D pid;=0A=
   new->uid =3D uid;=0A=
   new->highlight =3D 0;=0A=
+  new->argc =3D 0;=0A=
+  new->argv =3D 0;=0A=
 #ifdef FLASK_LINUX=0A=
   new->sid =3D sid;=0A=
 #endif /*FLASK_LINUX*/=0A=


------=_NextPart_000_024B_01C68E4C.BDFED110
Content-Type: text/plain; charset=us-ascii

--
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple
Problem reports:       http://cygwin.com/problems.html
Documentation:         http://cygwin.com/docs.html
FAQ:                   http://cygwin.com/faq/
------=_NextPart_000_024B_01C68E4C.BDFED110--

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019