unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
From: Eli Zaretskii <eliz@gnu.org>
To: Andreas Politz <politza@hochschule-trier.de>
Cc: 36609@debbugs.gnu.org
Subject: bug#36609: 27.0.50; Possible race-condition in threading implementation
Date: Fri, 12 Jul 2019 10:47:37 +0300	[thread overview]
Message-ID: <83sgrb3d9i.fsf@gnu.org> (raw)
In-Reply-To: <87muhks3b5.fsf@hochschule-trier.de> (message from Andreas Politz on Thu, 11 Jul 2019 22:51:10 +0200)

> From: Andreas Politz <politza@hochschule-trier.de>
> Date: Thu, 11 Jul 2019 22:51:10 +0200
> 
> I think there is a race-condition in the implementation of threads.

Not sure what you mean by "race condition".  Since only one Lisp
thread can run at any given time, where could this race happen, and
between what threads?

> I tried to find a minimal test-case, without success.  Thus, I've
> attached a lengthy source-file.  Loading that file should trigger
> this bug and may freeze your session.

FWIW, it doesn't freeze my Emacs here, neither on GNU/Linux nor on
MS-Windows (with today's master).  Are you getting freezes with 100%
reproducibility?  If so, please show all the details of your build, as
collected by report-emacs-bug.

> Indications:
> 
> 1. The main-thread has the name of one of created threads (XEmacs in
>    this case), instead of "emacs".

I don't think this is related to the problem.  I think we have a bug
in the implementation of the 'name' attribute of threads: we call
prctl(PR_SET_NAME), which AFAIU changes the name of the _calling_
thread, and the calling thread at that point is the main thread, see
sys_thread_create.  If I evaluate this:

  (make-thread 'ignore "XEmacs")

and then attach a debugger, I see that the name of the main thread has
changed to "XEmacs".

> 2. Emacs stops processing all keyboard/mouse input while looping in
>    wait_reading_process_output.  Sending commands via emacsclient still
>    works.
> 
> GDB output:
> 
> (gdb) info threads
>   Id   Target Id                                        Frame 
> * 1    Thread 0x7ffff17f5d40 (LWP 26264) "XEmacs"       0x000055555576eac0 in XPNTR (a=XIL(0x7ffff1312533)) at alloc.c:535
>   2    Thread 0x7ffff0ac4700 (LWP 26265) "gmain"        0x00007ffff50d1667 in poll () from /usr/lib/libc.so.6
>   3    Thread 0x7fffebd1a700 (LWP 26266) "gdbus"        0x00007ffff50d1667 in poll () from /usr/lib/libc.so.6
>   4    Thread 0x7fffeb519700 (LWP 26267) "dconf worker" 0x00007ffff50d1667 in poll () from /usr/lib/libc.so.6
> 
> (gdb) bt full

This "bt full" is not enough, because it shows the backtrace of one
thread only, the main thread.  Please show the backtrace of the other
3 threads by typing "thread apply all bt full" instead.

> #5  0x0000555555802a78 in wait_reading_process_output (time_limit=0, nsecs=0, read_kbd=-1, do_display=true, wait_for_cell=XIL(0), wait_proc=0x0, just_wait_proc=0) at process.c:5423
>         process_skipped = false
>         channel = 6
>         nfds = 1
>         Available = {
>           fds_bits = {32, 0 <repeats 15 times>}
>         }

Is the keyboard descriptor's bit in Available set or not?  What is the
contents of the fd_callback_info array at this point?

> ;; -*- lexical-binding: t -*-
> 
> (require 'threads)
> (require 'eieio)
> (require 'cl-lib)
> (require 'ring)
> 
> (defun debug (fmt &rest args)
>   (princ (apply #'format fmt args) #'external-debugging-output)
>   (terpri #'external-debugging-output))

Please describe what this program tries to accomplish, and how.  It's
not easy to reverse-engineer that from 200 lines of non-trivial code.
It's possible that the reason(s) for the freeze will be apparent from
describing your implementation ideas.

Thanks.





  reply	other threads:[~2019-07-12  7:47 UTC|newest]

Thread overview: 53+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-07-11 20:51 bug#36609: 27.0.50; Possible race-condition in threading implementation Andreas Politz
2019-07-12  7:47 ` Eli Zaretskii [this message]
2019-07-12  8:05   ` Eli Zaretskii
2019-07-12  9:02 ` Pip Cet
2019-07-12 12:42   ` Eli Zaretskii
2019-07-12 12:57     ` Pip Cet
2019-07-12 13:31       ` Eli Zaretskii
2019-07-12 13:51         ` Pip Cet
2019-07-12 15:05           ` Eli Zaretskii
2019-07-12 18:06             ` Pip Cet
2019-07-12 18:27               ` Eli Zaretskii
2019-07-12 18:34                 ` Eli Zaretskii
2019-07-12 19:24                   ` Pip Cet
2019-07-12 19:57                     ` Eli Zaretskii
2019-07-13 14:37                       ` Pip Cet
2019-07-13 15:03                         ` Eli Zaretskii
2019-07-13 15:13                           ` Eli Zaretskii
2019-07-13 15:54                           ` Eli Zaretskii
2019-07-13 15:57                             ` Pip Cet
2019-07-13 16:02                               ` Eli Zaretskii
2019-07-13 18:17                                 ` Pip Cet
2020-08-21 12:57                                   ` Lars Ingebrigtsen
2019-07-13 15:04                         ` Andreas Politz
2019-07-12 12:44   ` Pip Cet
2019-07-12 12:55     ` Eli Zaretskii
2019-07-12 13:40       ` Pip Cet
2019-07-12 13:51         ` Eli Zaretskii
2019-07-12 14:34           ` Pip Cet
2019-07-12 15:02             ` Eli Zaretskii
2019-07-12 19:30               ` Pip Cet
2019-07-13  6:50                 ` Eli Zaretskii
2021-06-06 15:50 ` dick.r.chiang
     [not found] ` <87fsxv8182.fsf@dick>
2021-06-06 16:35   ` Eli Zaretskii
2021-06-06 19:10     ` dick.r.chiang
2021-06-06 19:27       ` Eli Zaretskii
2021-06-09 21:40         ` dick.r.chiang
2021-06-10  6:46           ` Eli Zaretskii
2021-06-10 11:52             ` dick.r.chiang
2021-06-10 14:18               ` Eli Zaretskii
2021-06-10 14:55                 ` dick.r.chiang
2021-06-10 15:04                   ` Eli Zaretskii
2021-06-10 21:36                     ` dick.r.chiang
2021-06-11  6:00                       ` Eli Zaretskii
2021-06-19 17:53                         ` Eli Zaretskii
2021-06-19 19:14                           ` dick.r.chiang
2021-06-19 19:18                             ` Eli Zaretskii
2021-06-19 21:12                               ` dick.r.chiang
2021-06-20 11:39                                 ` Eli Zaretskii
2021-06-20 14:01                                   ` dick.r.chiang
2021-06-20 15:53                                     ` Eli Zaretskii
2021-06-25 13:54                                       ` Eli Zaretskii
2021-06-10 15:35                 ` Andreas Schwab
2021-06-10 15:39                   ` 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=83sgrb3d9i.fsf@gnu.org \
    --to=eliz@gnu.org \
    --cc=36609@debbugs.gnu.org \
    --cc=politza@hochschule-trier.de \
    /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).