GNU bug report logs - #36279
26.2.90; (process-attributes nonexistent-pid) segmentation fault

Previous Next

Package: emacs;

Reported by: Xu Chunyang <mail <at> xuchunyang.me>

Date: Tue, 18 Jun 2019 13:27:02 UTC

Severity: normal

Tags: fixed

Found in version 26.2.90

Fixed in version 26.3

Done: Robert Pluim <rpluim <at> gmail.com>

Bug is archived. No further changes may be made.

Full log


Message #14 received at 36279 <at> debbugs.gnu.org (full text, mbox):

From: Robert Pluim <rpluim <at> gmail.com>
To: xuchunyang <mail <at> xuchunyang.me>
Cc: 36279 <at> debbugs.gnu.org, Noam Postavsky <npostavs <at> gmail.com>
Subject: Re: bug#36279: 26.2.90;
 (process-attributes nonexistent-pid) segmentation fault
Date: Tue, 18 Jun 2019 17:23:08 +0200
>>>>> On Tue, 18 Jun 2019 22:05:38 +0800, xuchunyang <mail <at> xuchunyang.me> said:

    xuchunyang> On Tue, Jun 18, 2019, at 9:31 PM, Noam Postavsky wrote:
    >> Xu Chunyang <mail <at> xuchunyang.me> writes:
    >> 
    >> > Emacs crashes when I run the following (the PID 123456 doesn't exist)
    >> >
    >> >     (process-attributes 123456)
    >> >
    >> > And I can reproduce it from Emacs -Q:
    >> >
    >> >     ~ $ emacs -Q --batch --eval '(print (process-attributes 123456))'
    >> >     Fatal error 11: Segmentation faultzsh: segmentation fault  emacs -Q --batch --eval '(print (process-attributes 123456))'
    >> >     ~ $ emacs --version | head -1
    >> >     GNU Emacs 26.2.90
    >> >     ~ $
    >> >
    >> >
    >> > In GNU Emacs 26.2.90 (build 1, x86_64-apple-darwin18.6.0, Carbon Version 158 AppKit 1671.5)
    >> 
    >> Doesn't happen here[1], I just get nil.  Can you show a backtrace with a
    >> gdb (or lldb if that's not available)?

I get the same crash here. You'd expect sysctl to return an error when
requesting info about a non-existent process, but instead it
passive-agressively sets proclen to 0. This fixes it for me here, can
you try it?

diff --git a/src/sysdep.c b/src/sysdep.c
index 1e35e06b63..518ecebcf6 100644
--- a/src/sysdep.c
+++ b/src/sysdep.c
@@ -3798,7 +3798,7 @@ system_process_attributes (Lisp_Object pid)
   CONS_TO_INTEGER (pid, int, proc_id);
   mib[3] = proc_id;
 
-  if (sysctl (mib, 4, &proc, &proclen, NULL, 0) != 0)
+  if (sysctl (mib, 4, &proc, &proclen, NULL, 0) != 0 || proclen == 0)
     return attrs;
 
   uid = proc.kp_eproc.e_ucred.cr_uid;




This bug report was last modified 5 years and 342 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.