unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
From: Robert Pluim <rpluim@gmail.com>
To: xuchunyang <mail@xuchunyang.me>
Cc: 36279@debbugs.gnu.org, Noam Postavsky <npostavs@gmail.com>
Subject: bug#36279: 26.2.90; (process-attributes nonexistent-pid) segmentation fault
Date: Tue, 18 Jun 2019 17:23:08 +0200	[thread overview]
Message-ID: <m21rzqncir.fsf@gmail.com> (raw)
In-Reply-To: <42c23bd8-57e3-4503-a6cf-d38aec89edd0@www.fastmail.com> (xuchunyang's message of "Tue, 18 Jun 2019 22:05:38 +0800")

>>>>> On Tue, 18 Jun 2019 22:05:38 +0800, xuchunyang <mail@xuchunyang.me> said:

    xuchunyang> On Tue, Jun 18, 2019, at 9:31 PM, Noam Postavsky wrote:
    >> Xu Chunyang <mail@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;





  reply	other threads:[~2019-06-18 15:23 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-06-18 13:25 bug#36279: 26.2.90; (process-attributes nonexistent-pid) segmentation fault Xu Chunyang
2019-06-18 13:31 ` Noam Postavsky
2019-06-18 14:05   ` xuchunyang
2019-06-18 15:23     ` Robert Pluim [this message]
2019-06-18 16:23       ` xuchunyang
2019-06-18 17:44         ` Eli Zaretskii
2019-06-18 17:53           ` Robert Pluim
2019-06-18 18:06             ` Eli Zaretskii
2019-06-18 18:14               ` Robert Pluim
2019-06-19  7:06                 ` Robert Pluim
2019-06-19  8:01                   ` Andreas Schwab
2019-06-19 10:21                     ` Robert Pluim
2019-06-19 10:29                       ` Andreas Schwab
2019-06-19 13:40                         ` Robert Pluim
2019-06-19 15:15                   ` Eli Zaretskii
2019-06-20  8:46                     ` Robert Pluim
2019-06-18 16:10     ` Eli Zaretskii
2019-06-18 16:07 ` Eli Zaretskii

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

  List information: https://www.gnu.org/software/emacs/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=m21rzqncir.fsf@gmail.com \
    --to=rpluim@gmail.com \
    --cc=36279@debbugs.gnu.org \
    --cc=mail@xuchunyang.me \
    --cc=npostavs@gmail.com \
    /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: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

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).