GNU bug report logs - #33198
27.0.50; emacs_abort on EBADF during accept-process-output in non-main thread

Please note: This is a static page, with minimal formatting, updated once a day.
Click here to see this page with the latest information and nicer formatting.

Package: emacs; Reported by: Gemini Lasswell <gazally@HIDDEN>; dated Mon, 29 Oct 2018 22:12:01 UTC; Maintainer for emacs is bug-gnu-emacs@HIDDEN.

Message received at 33198 <at> debbugs.gnu.org:


Received: (at 33198) by debbugs.gnu.org; 30 Oct 2018 06:50:27 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Tue Oct 30 02:50:27 2018
Received: from localhost ([127.0.0.1]:53145 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1gHNr9-0001wt-8F
	for submit <at> debbugs.gnu.org; Tue, 30 Oct 2018 02:50:27 -0400
Received: from eggs.gnu.org ([208.118.235.92]:58180)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <eliz@HIDDEN>) id 1gHNr7-0001wh-JP
 for 33198 <at> debbugs.gnu.org; Tue, 30 Oct 2018 02:50:25 -0400
Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71)
 (envelope-from <eliz@HIDDEN>) id 1gHNqr-0005ZZ-W7
 for 33198 <at> debbugs.gnu.org; Tue, 30 Oct 2018 02:50:15 -0400
X-Spam-Checker-Version: SpamAssassin 3.3.2 (2011-06-06) on eggs.gnu.org
X-Spam-Level: 
X-Spam-Status: No, score=-0.5 required=5.0 tests=BAYES_05 autolearn=disabled
 version=3.3.2
Received: from fencepost.gnu.org ([2001:4830:134:3::e]:58747)
 by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from <eliz@HIDDEN>)
 id 1gHNqr-0005YR-NZ; Tue, 30 Oct 2018 02:50:09 -0400
Received: from [176.228.60.248] (port=1146 helo=home-c4e4a596f7)
 by fencepost.gnu.org with esmtpsa (TLS1.2:RSA_AES_256_CBC_SHA1:256)
 (Exim 4.82) (envelope-from <eliz@HIDDEN>)
 id 1gHNqq-0002nV-KV; Tue, 30 Oct 2018 02:50:09 -0400
Date: Tue, 30 Oct 2018 08:50:19 +0200
Message-Id: <83lg6gkjx0.fsf@HIDDEN>
From: Eli Zaretskii <eliz@HIDDEN>
To: Gemini Lasswell <gazally@HIDDEN>
In-reply-to: <87d0rsjteo.fsf@HIDDEN> (message from Gemini Lasswell on Mon, 
 29 Oct 2018 15:10:39 -0700)
Subject: Re: bug#33198: 27.0.50;
 emacs_abort on EBADF during accept-process-output in non-main thread
References: <87d0rsjteo.fsf@HIDDEN>
X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic]
X-Received-From: 2001:4830:134:3::e
X-Spam-Score: -5.0 (-----)
X-Debbugs-Envelope-To: 33198
Cc: 33198 <at> debbugs.gnu.org
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -6.0 (------)

> From: Gemini Lasswell <gazally@HIDDEN>
> Date: Mon, 29 Oct 2018 15:10:39 -0700
> 
> I've hit the emacs_abort at line 5510 in process.c a few times in the
> last week.  I haven't found a way to make it reproduce on demand.  I
> tried to narrow the code it's happening in down to a smaller test case,
> without success.  I'd appreciate suggestions for how to track down what
> is going wrong.

I suggest to instrument the code that determines which thread will
listen to what descriptors in its pselect call.  This happens inside
compute_input_wait_mask and compute_non_keyboard_wait_mask, and the
data those use is set by several add_*_fd functions.  The
instrumentation should output the descriptor, the thread ID, and what
is it used for.  Then I think you will be able to see where did the
bad descriptor come from, and how it happened to be bad.

You will also need to determine which descriptor is the bad one; the
usual paradigm to do that is by calling 'fcntl (fd, F_GETFD)' on each
descriptor on which pselect was asked to wait, and see which ones
return -1 with erno = EBADFD.




Information forwarded to bug-gnu-emacs@HIDDEN:
bug#33198; Package emacs. Full text available.

Message received at submit <at> debbugs.gnu.org:


Received: (at submit) by debbugs.gnu.org; 29 Oct 2018 22:11:11 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Mon Oct 29 18:11:11 2018
Received: from localhost ([127.0.0.1]:52281 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1gHFkd-0003ol-1i
	for submit <at> debbugs.gnu.org; Mon, 29 Oct 2018 18:11:11 -0400
Received: from eggs.gnu.org ([208.118.235.92]:49455)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <gazally@HIDDEN>) id 1gHFkY-0003oI-5u
 for submit <at> debbugs.gnu.org; Mon, 29 Oct 2018 18:11:09 -0400
Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71)
 (envelope-from <gazally@HIDDEN>) id 1gHFkR-0001hU-Lo
 for submit <at> debbugs.gnu.org; Mon, 29 Oct 2018 18:11:01 -0400
X-Spam-Checker-Version: SpamAssassin 3.3.2 (2011-06-06) on eggs.gnu.org
X-Spam-Level: 
X-Spam-Status: No, score=0.8 required=5.0 tests=BAYES_50,FREEMAIL_FROM
 autolearn=disabled version=3.3.2
Received: from lists.gnu.org ([2001:4830:134:3::11]:56978)
 by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32)
 (Exim 4.71) (envelope-from <gazally@HIDDEN>) id 1gHFkR-0001hI-GD
 for submit <at> debbugs.gnu.org; Mon, 29 Oct 2018 18:10:59 -0400
Received: from eggs.gnu.org ([2001:4830:134:3::10]:59059)
 by lists.gnu.org with esmtp (Exim 4.71)
 (envelope-from <gazally@HIDDEN>) id 1gHFkQ-0006Kh-2P
 for bug-gnu-emacs@HIDDEN; Mon, 29 Oct 2018 18:10:59 -0400
Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71)
 (envelope-from <gazally@HIDDEN>) id 1gHFkL-0001bE-Q5
 for bug-gnu-emacs@HIDDEN; Mon, 29 Oct 2018 18:10:58 -0400
Received: from aibo.runbox.com ([91.220.196.211]:43304)
 by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16)
 (Exim 4.71) (envelope-from <gazally@HIDDEN>) id 1gHFkL-0001aO-Cw
 for bug-gnu-emacs@HIDDEN; Mon, 29 Oct 2018 18:10:53 -0400
DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=runbox.com; 
 s=rbselector1;
 h=Content-Type:MIME-Version:Message-ID:Date:Subject:To:From; 
 bh=xrDjgNwaIfKYWN+idxwMBSl/l9WDi5TrtqUm6y9MzaM=; b=SpkA/kDWKwO12d/YKcHJFZjvb
 aL3BSTtlYocIaSx0FBLigT0GN/sQexp8dauB4s+QIxvCgQ7ddYj4Yl/4p2UzWyyltd9Yy61D8ula6
 OM3gbTAPZj6/3T71/bOzO9RNgSn9KmELY38zbz9g9zbrrOCtZhDhfEhxV3XSr+XCQyiT2CgfiZtyO
 FkWpABqCWTOlAHDsF9SNtoGeG7l1Wwgta/DTZagY9OEAXATpgieVVT3/pG0wsTmL87PkXKouxugJh
 wXhwRLiKtyGPT/AeDDXuUKTfiM7VjrD3BC5aomsIws5oBMntbTor4V9jl2M90M6XjxcaAuzbwE+Li
 KeRjjXjtA==;
Received: from [10.9.9.210] (helo=mailfront10.runbox.com)
 by mailtransmit03.runbox with esmtp (Exim 4.86_2)
 (envelope-from <gazally@HIDDEN>) id 1gHFkJ-0007yZ-MM
 for bug-gnu-emacs@HIDDEN; Mon, 29 Oct 2018 23:10:51 +0100
Received: by mailfront10.runbox.com with esmtpsa (uid:179284 )
 (TLS1.2:RSA_AES_256_CBC_SHA1:256) (Exim 4.82) id 1gHFk9-00049C-GE
 for bug-gnu-emacs@HIDDEN; Mon, 29 Oct 2018 23:10:42 +0100
From: Gemini Lasswell <gazally@HIDDEN>
To: bug-gnu-emacs@HIDDEN
Subject: 27.0.50;
 emacs_abort on EBADF during accept-process-output in non-main thread
Date: Mon, 29 Oct 2018 15:10:39 -0700
Message-ID: <87d0rsjteo.fsf@HIDDEN>
MIME-Version: 1.0
Content-Type: multipart/mixed; boundary="=-=-="
X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic]
X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6.x
X-Received-From: 2001:4830:134:3::11
X-Spam-Score: -4.1 (----)
X-Debbugs-Envelope-To: submit
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -5.1 (-----)

--=-=-=
Content-Type: text/plain

I've hit the emacs_abort at line 5510 in process.c a few times in the
last week.  I haven't found a way to make it reproduce on demand.  I
tried to narrow the code it's happening in down to a smaller test case,
without success.  I'd appreciate suggestions for how to track down what
is going wrong.

I'm working on a Lisp program which has work to do which can be done in
parallel, and I'm implementing it using threads.  My code has 4 worker
threads which pick jobs to do off of a queue (which is made thread-safe
with a mutex and condition variables).  The jobs consist of an argument
to a shell script, which the threads run asynchronously using
start-file-process and accept-process-output.  This allows the worker
threads to be responsive to a user command to cancel the work in
progress, although I haven't been using that cancel command when the bug
happens.  When it has happened, it's been after I run a command which
adds 6 jobs to the queue for the 4 threads to process.

The crash has happened with two different shell scripts, one which just
consists of "exit 1" and another which makes a directory and a symlink.
Neither script prints anything to standard output.

I've tried using the process object instead of nil as the first argument
to accept-process-output and have seen the same crash both ways.

Here are the two main functions in my worker threads,
'erb--builder-func' which is passed to 'make-thread' to create the
threads, and 'erb--build' which runs the child processes.


--=-=-=
Content-Type: text/plain
Content-Disposition: attachment; filename=erb-build.el

(defun erb--builder-func ()
  "Build commits from `erb--unbuilt-commits'."
  (catch 'stop
    (while t
      (condition-case err
          (let ((commit (thread-queue-get erb--unbuilt-commits))
                build-result)
            (when (eq commit 'stop)
              (message "ERB builder thread stopping")
              (throw 'stop nil))

            (erb--status-remove commit 'waiting-to-build)
            (erb--status-add commit 'building)

            (unwind-protect
                (let ((job (thread-message-value erb--job)))
                  (unless (eq job 'cancel)
                    (with-current-buffer (erb--job-buffer job)
                      (setq build-result (erb--build commit)))))

              (erb--status-remove commit 'building)
              (if build-result
                  (erb--status-add commit 'built)
                (erb--status-add commit 'failed-builds))
              (thread-queue-put (list commit build-result)
                                erb--built-commits)))

        ((error quit) (message "Error in ERB benchmark build thread: %s" err))))))

(defun erb--build (commit)
  "Build Emacs from COMMIT.
Run the build in an asynchonous process in a temporary directory.
Save the directory name if the build is successful.  If the build
fails, save the output of the build script in the file COMMIT.log
in the results/MACHINE/failed-builds directory of
`erb-suite-directory'."
  (let* ((temp-dir (file-name-as-directory (make-temp-file "erb" t)))
         (default-directory temp-dir)
         (name (format "ERB-build-%s" commit))
         (outbuf (generate-new-buffer name))
         (build-script (erb--get-build-script-filename))
         process success)

    (unwind-protect
        (map-let (project-repo) erb--config
          (setq process
                (condition-case _err
                    (start-file-process name outbuf build-script project-repo
                                        commit)
                  ((error quit) nil)))
          (if (null process)
              (progn
                (message "Failed to start build process for commit `%s'"
                         commit)
                (erb-run--record-failure commit "Failed to start build process"))
            (catch 'quit
              (while (process-live-p process)
                (accept-process-output nil 0.5)
                (when (erb--cancel-now-p)
                  (delete-process process)
                  (throw 'quit nil)))
              (if (= (process-exit-status process) 0)
                  (progn
                    (setq success temp-dir)
                    (erb-run--remove-old-failure commit))
                (message "Building commit `%s' failed" commit)
                (erb-run--record-failure commit outbuf)))))
      (unless success
	(delete-directory temp-dir t))
      (kill-buffer outbuf))
    success))

--=-=-=
Content-Type: text/plain


Thread 6 "ERB control" hit Breakpoint 1, terminate_due_to_signal (
    sig=sig@entry=6, backtrace_limit=backtrace_limit@entry=40) at emacs.c:369
369	{
(gdb) bt
#0  terminate_due_to_signal (sig=sig@entry=6,
    backtrace_limit=backtrace_limit@entry=40) at emacs.c:369
#1  0x0000000000511a23 in emacs_abort () at sysdep.c:2429
#2  0x00000000005b68c1 in wait_reading_process_output (
    time_limit=<optimized out>, nsecs=<optimized out>, read_kbd=read_kbd@entry=0,
    do_display=do_display@entry=false, wait_for_cell=wait_for_cell@entry=XIL(0),
    wait_proc=<optimized out>, just_wait_proc=0) at process.c:5510
#3  0x00000000005b6eea in Faccept_process_output (process=XIL(0),
    seconds=<optimized out>, millisec=<optimized out>, just_this_one=XIL(0))
    at process.c:4677
#4  0x000000000056e815 in Ffuncall (nargs=3, args=args@entry=0x7fffd366d360)
    at eval.c:2856
#5  0x00000000005aa740 in exec_byte_code (bytestr=<optimized out>,
    vector=<optimized out>, maxdepth=<optimized out>,
    args_template=<optimized out>, nargs=nargs@entry=1, args=<optimized out>,
    args@entry=0x15dede8 <bss_sbrk_buffer+10104552>) at bytecode.c:632
#6  0x0000000000571416 in funcall_lambda (fun=XIL(0x7fffd366d360),
    nargs=nargs@entry=1, arg_vector=0x15dede8 <bss_sbrk_buffer+10104552>,
    arg_vector@entry=0x7fffd366d600) at eval.c:3057
#7  0x000000000056e793 in Ffuncall (nargs=2, args=args@entry=0x7fffd366d5f8)
    at eval.c:2870
#8  0x00000000005aa740 in exec_byte_code (bytestr=<optimized out>,
    vector=<optimized out>, maxdepth=<optimized out>,
    args_template=<optimized out>, nargs=nargs@entry=0, args=<optimized out>,
    args@entry=0x15deca8 <bss_sbrk_buffer+10104232>) at bytecode.c:632
#9  0x0000000000571416 in funcall_lambda (fun=XIL(0x7fffd366d5f8),
    nargs=nargs@entry=0, arg_vector=0x15deca8 <bss_sbrk_buffer+10104232>,
    arg_vector@entry=0x1423c58 <bss_sbrk_buffer+8289624>) at eval.c:3057
#10 0x000000000056e793 in Ffuncall (nargs=nargs@entry=1,
    args=args@entry=0x1423c50 <bss_sbrk_buffer+8289616>) at eval.c:2870
#11 0x00000000005d425b in invoke_thread_function () at thread.c:684
#12 0x000000000056d9ef in internal_condition_case (
    bfun=bfun@entry=0x5d4220 <invoke_thread_function>,
    handlers=handlers@entry=XIL(0xc3c0),
    hfun=hfun@entry=0x5d3ae0 <record_thread_error>) at eval.c:1373
#13 0x00000000005d414b in run_thread (state=0x1423c30 <bss_sbrk_buffer+8289584>)
    at thread.c:723
#14 0x00007ffff15a65a7 in start_thread ()
   from /nix/store/fg4yq8i8wd08xg3fy58l6q73cjy8hjr2-glibc-2.27/lib/libpthread.so.0
#15 0x00007ffff0c4122f in clone ()
   from /nix/store/fg4yq8i8wd08xg3fy58l6q73cjy8hjr2-glibc-2.27/lib/libc.so.6

Lisp Backtrace:
"accept-process-output" (0xd366d368)
"erb--build" (0xd366d600)
"erb--builder-func" (0x1423c58)


In GNU Emacs 27.0.50 (build 8, x86_64-pc-linux-gnu, GTK+ Version 3.22.30)
 of 2018-10-28 built on sockeye
Repository revision: f7638edcb06fac3b58b986062ea679f6919d81d7
Windowing system distributor 'The X.Org Foundation', version 11.0.11906000
System Description: NixOS 18.09.git.ad56635 (Jellyfish)

Recent messages:
For information about GNU Emacs and the GNU system, type C-h C-a.

Configured using:
 'configure --prefix=/home/gem/src/emacs/master/bin --with-modules
 --with-x-toolkit=gtk3 --with-xft --config-cache'

Configured features:
XPM JPEG TIFF GIF PNG RSVG SOUND DBUS GSETTINGS GLIB NOTIFY LIBSELINUX
GNUTLS LIBXML2 FREETYPE XFT ZLIB TOOLKIT_SCROLL_BARS GTK3 X11 XDBE XIM
MODULES THREADS GMP

Important settings:
  value of $EMACSLOADPATH:
  value of $LANG: en_US.UTF-8
  locale-coding-system: utf-8-unix

Major mode: Lisp Interaction

Minor modes in effect:
  tooltip-mode: t
  global-eldoc-mode: t
  eldoc-mode: t
  electric-indent-mode: t
  mouse-wheel-mode: t
  tool-bar-mode: t
  menu-bar-mode: t
  file-name-shadow-mode: t
  global-font-lock-mode: t
  font-lock-mode: t
  blink-cursor-mode: t
  auto-composition-mode: t
  auto-encryption-mode: t
  auto-compression-mode: t
  line-number-mode: t
  transient-mark-mode: t

Load-path shadows:
None found.

Features:
(shadow sort mail-extr emacsbug message rmc puny seq byte-opt gv
bytecomp byte-compile cconv dired dired-loaddefs format-spec rfc822 mml
easymenu mml-sec password-cache epa derived epg epg-config gnus-util
rmail rmail-loaddefs time-date mm-decode mm-bodies mm-encode mail-parse
rfc2231 mailabbrev gmm-utils mailheader cl-loaddefs cl-lib sendmail
rfc2047 rfc2045 ietf-drums mm-util mail-prsvr mail-utils elec-pair
mule-util tooltip eldoc electric uniquify ediff-hook vc-hooks
lisp-float-type mwheel term/x-win x-win term/common-win x-dnd tool-bar
dnd fontset image regexp-opt fringe tabulated-list replace newcomment
text-mode elisp-mode lisp-mode prog-mode register page menu-bar
rfn-eshadow isearch timer select scroll-bar mouse jit-lock font-lock
syntax facemenu font-core term/tty-colors frame cl-generic cham georgian
utf-8-lang misc-lang vietnamese tibetan thai tai-viet lao korean
japanese eucjp-ms cp51932 hebrew greek romanian slovak czech european
ethiopic indian cyrillic chinese composite charscript charprop
case-table epa-hook jka-cmpr-hook help simple abbrev obarray minibuffer
cl-preloaded nadvice loaddefs button faces cus-face macroexp files
text-properties overlay sha1 md5 base64 format env code-pages mule
custom widget hashtable-print-readable backquote threads dbusbind
inotify dynamic-setting system-font-setting font-render-setting
move-toolbar gtk x-toolkit x multi-tty make-network-process emacs)

Memory information:
((conses 16 95415 9749)
 (symbols 48 20031 1)
 (strings 32 28349 1783)
 (string-bytes 1 753921)
 (vectors 16 14931)
 (vector-slots 8 508718 9684)
 (floats 8 47 70)
 (intervals 56 209 0)
 (buffers 992 11))

--=-=-=--




Acknowledgement sent to Gemini Lasswell <gazally@HIDDEN>:
New bug report received and forwarded. Copy sent to bug-gnu-emacs@HIDDEN. Full text available.
Report forwarded to bug-gnu-emacs@HIDDEN:
bug#33198; Package emacs. Full text available.
Please note: This is a static page, with minimal formatting, updated once a day.
Click here to see this page with the latest information and nicer formatting.
Last modified: Mon, 25 Nov 2019 12:00:02 UTC

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