From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED.blaine.gmane.org!not-for-mail From: xuchunyang Newsgroups: gmane.emacs.bugs Subject: bug#36279: 26.2.90; (process-attributes nonexistent-pid) segmentation fault Date: Wed, 19 Jun 2019 00:23:20 +0800 Message-ID: <3593bb18-c70f-4759-bf34-a245cf1ddf9b@www.fastmail.com> References: <87zhmfvx44.fsf@gmail.com> <42c23bd8-57e3-4503-a6cf-d38aec89edd0@www.fastmail.com> Mime-Version: 1.0 Content-Type: text/plain Injection-Info: blaine.gmane.org; posting-host="blaine.gmane.org:195.159.176.226"; logging-data="225321"; mail-complaints-to="usenet@blaine.gmane.org" User-Agent: Cyrus-JMAP/3.1.6-666-gb2312fa-fmstable-20190614v4 Cc: 36279@debbugs.gnu.org, Noam Postavsky To: "Robert Pluim" Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Tue Jun 18 18:57:54 2019 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([209.51.188.17]) by blaine.gmane.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.89) (envelope-from ) id 1hdHQf-000wSp-4w for geb-bug-gnu-emacs@m.gmane.org; Tue, 18 Jun 2019 18:57:54 +0200 Original-Received: from localhost ([::1]:60074 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hdHQe-0002hp-59 for geb-bug-gnu-emacs@m.gmane.org; Tue, 18 Jun 2019 12:57:52 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:52094) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hdGtx-0003Vf-SM for bug-gnu-emacs@gnu.org; Tue, 18 Jun 2019 12:24:06 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hdGtw-0001C9-Ci for bug-gnu-emacs@gnu.org; Tue, 18 Jun 2019 12:24:05 -0400 Original-Received: from debbugs.gnu.org ([209.51.188.43]:60168) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1hdGtu-00017I-AZ for bug-gnu-emacs@gnu.org; Tue, 18 Jun 2019 12:24:04 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1hdGtu-0007Nv-66 for bug-gnu-emacs@gnu.org; Tue, 18 Jun 2019 12:24:02 -0400 X-Loop: help-debbugs@gnu.org Resent-From: xuchunyang Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Tue, 18 Jun 2019 16:24:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 36279 X-GNU-PR-Package: emacs Original-Received: via spool by 36279-submit@debbugs.gnu.org id=B36279.156087502428365 (code B ref 36279); Tue, 18 Jun 2019 16:24:02 +0000 Original-Received: (at 36279) by debbugs.gnu.org; 18 Jun 2019 16:23:44 +0000 Original-Received: from localhost ([127.0.0.1]:45479 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1hdGtc-0007NQ-5d for submit@debbugs.gnu.org; Tue, 18 Jun 2019 12:23:44 -0400 Original-Received: from wout2-smtp.messagingengine.com ([64.147.123.25]:60051) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1hdGtZ-0007NC-Ok for 36279@debbugs.gnu.org; Tue, 18 Jun 2019 12:23:42 -0400 Original-Received: from compute6.internal (compute6.nyi.internal [10.202.2.46]) by mailout.west.internal (Postfix) with ESMTP id CEEBD679; Tue, 18 Jun 2019 12:23:35 -0400 (EDT) Original-Received: from imap8 ([10.202.2.58]) by compute6.internal (MEProxy); Tue, 18 Jun 2019 12:23:36 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=xuchunyang.me; h=mime-version:message-id:in-reply-to:references:date:from:to :cc:subject:content-type; s=fm1; bh=EkjAz38za6mLtLTYKYCi0xBd8FOw 5PKaAn5Jd1GRHdg=; b=YSt00lujJpVSivfvcIfTJEm8Wjlg293c3LK2IsndCD/p xyw8xVDDuMyLhGFtOPIl0RvDyvYY/j9h27qMAl2EebUN8HeN8KtwJyR7XoCgbUEw qhKeR0c0JNq0F2wHN/ATyH4K91uoABgcVPLTeKSDcp4qgfLSUMFt88fIefMdxKsx 0UGxc4hdWU/k9cG5JMEQo6AJgOPD4O0NS2l//wzMBk4FP1JxikTMdx7CmsPoBXQJ U9mtaRb7KsC5b6QWeyXfnOgldX1YsKZtKWy972ZhZ4R5XjxjGdQtuklYXBX4TJ2H DNfb7f1yGSExk9DQsDyFT+dl0FDK8iHZW1VljR0r7Q== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:content-type:date:from:in-reply-to :message-id:mime-version:references:subject:to:x-me-proxy :x-me-proxy:x-me-sender:x-me-sender:x-sasl-enc; s=fm3; bh=EkjAz3 8za6mLtLTYKYCi0xBd8FOw5PKaAn5Jd1GRHdg=; b=oGDsmKlTqw8ObtPzTnOAQ8 XPhgAMI3sRoTcrjCAuRKLgkXcvUgPF8t9YqROBoMRLj7udnDKkU3ZesXuk3RyoOU 6LCpdujS0L7ArbsT8i64AsUOc6V447hY8nzcxDzt6BDyuB1GO5PzkEUl8mQDlB+S R4yh8OlzJ0oRiCXabalt/n+kXmqj36xJusEZfL0eJm7nTaF47WhyPTw6MHV+OC6A Tgik66wo7HBNGGPNUMPRHg5ErvCWRPRAQf5QZc7IGt8Zfvu6Tq4QVKT3tNi9bZPW A+YJmlOeCKnRwl315KDWmjMuvHSuSZ1bmOuJFcriK3kDcBegaIdkPJqd6rc5DbPQ == X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeduvddrtddtgdejudcutefuodetggdotefrodftvf curfhrohhfihhlvgemucfhrghsthforghilhdpqfgfvfdpuffrtefokffrpgfnqfghnecu uegrihhlohhuthemuceftddtnecusecvtfgvtghiphhivghnthhsucdlqddutddtmdenuc fjughrpefofgggkfgjfhffhffvufgtsehttdertderreejnecuhfhrohhmpeiguhgthhhu nhihrghnghcuoehmrghilhesgihutghhuhhnhigrnhhgrdhmvgeqnecurfgrrhgrmhepmh grihhlfhhrohhmpehmrghilhesgihutghhuhhnhigrnhhgrdhmvgenucevlhhushhtvghr ufhiiigvpedt X-ME-Proxy: Original-Received: by mailuser.nyi.internal (Postfix, from userid 501) id D76C6520093; Tue, 18 Jun 2019 12:23:34 -0400 (EDT) X-Mailer: MessagingEngine.com Webmail Interface In-Reply-To: X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 209.51.188.43 X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Original-Sender: "bug-gnu-emacs" Xref: news.gmane.org gmane.emacs.bugs:160776 Archived-At: On Tue, Jun 18, 2019, at 11:23 PM, Robert Pluim wrote: > >>>>> On Tue, 18 Jun 2019 22:05:38 +0800, xuchunyang said: > > xuchunyang> On Tue, Jun 18, 2019, at 9:31 PM, Noam Postavsky wrote: > >> Xu Chunyang 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? It fixes the issue for me too. (process-attributes 123456) returns nil instead of crashing Emacs. > > 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; >