all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Juanma Barranquero <lekktu@gmail.com>
To: 10044@debbugs.gnu.org
Subject: bug#10044: "warning: reader_thread.SetEvent failed with 6 for fd -1" and accessing fd_info[-1]
Date: Mon, 14 Nov 2011 16:33:42 +0100	[thread overview]
Message-ID: <CAAeL0ST2o9G_MT6wMGRbZV8pnWeoP4TXB4FZjNYzgh_VsRL6jg@mail.gmail.com> (raw)

Package: emacs,w32
Severity: minor

  (gdb) run -Q --eval "(shell-command \"dir\")"
  Starting program: c:\emacs\debug\bin\emacs.exe -Q --eval
"(shell-command \"dir\")"
  [New Thread 5948.0x17a4]
  [New Thread 5948.0x9c8]
  [New Thread 5948.0x4b4]
  [New Thread 5948.0x16ac]
  warning: reader_thread.SetEvent failed with 6 for fd -1

which can not be right, because it happens in this bit of code of
w32proc.c:reader_thread():

  /* Our identity */
  cp = (child_process *)arg;

  /* We have to wait for the go-ahead before we can start */
  if (cp == NULL
      || WaitForSingleObject (cp->char_consumed, INFINITE) != WAIT_OBJECT_0)
    return 1;

  for (;;)
    {
      int rc;

      if (fd_info[cp->fd].flags & FILE_LISTEN)
	rc = _sys_wait_accept (cp->fd);
      else
	rc = _sys_read_ahead (cp->fd);

      /* The name char_avail is a misnomer - it really just means the
	 read-ahead has completed, whether successfully or not. */
      if (!SetEvent (cp->char_avail))
        {
	  DebPrint (("reader_thread.SetEvent failed with %lu for fd %ld\n",
		     GetLastError (), cp->fd));
	  return 1;
	}

   [...]

which means that cp->fd is being used as an index into fd_info[], and
the choice between _sys_wait_accept and _sys_read_ahead is bogus.

IIUC, cp->fd == -1 means that the wait was intended, but no input is
expected, so I think the following patch is enough:


=== modified file 'src/w32proc.c'
--- src/w32proc.c       2011-06-24 21:25:22 +0000
+++ src/w32proc.c       2011-11-14 15:19:09 +0000
@@ -241,7 +241,8 @@

   /* We have to wait for the go-ahead before we can start */
   if (cp == NULL
-      || WaitForSingleObject (cp->char_consumed, INFINITE) != WAIT_OBJECT_0)
+      || WaitForSingleObject (cp->char_consumed, INFINITE) != WAIT_OBJECT_0
+      || cp->fd < 0)
     return 1;

   for (;;)





             reply	other threads:[~2011-11-14 15:33 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-11-14 15:33 Juanma Barranquero [this message]
2011-11-14 17:14 ` bug#10044: "warning: reader_thread.SetEvent failed with 6 for fd -1" and accessing fd_info[-1] Eli Zaretskii
2011-11-14 17:30   ` Juanma Barranquero
2011-11-14 17:53     ` Juanma Barranquero

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

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

  git send-email \
    --in-reply-to=CAAeL0ST2o9G_MT6wMGRbZV8pnWeoP4TXB4FZjNYzgh_VsRL6jg@mail.gmail.com \
    --to=lekktu@gmail.com \
    --cc=10044@debbugs.gnu.org \
    /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 external index

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

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.