GNU bug report logs - #10044
"warning: reader_thread.SetEvent failed with 6 for fd -1" and accessing fd_info[-1]

Previous Next

Packages: w32, emacs;

Reported by: Juanma Barranquero <lekktu <at> gmail.com>

Date: Mon, 14 Nov 2011 15:36:01 UTC

Severity: minor

Done: Juanma Barranquero <lekktu <at> gmail.com>

Bug is archived. No further changes may be made.

To add a comment to this bug, you must first unarchive it, by sending
a message to control AT debbugs.gnu.org, with unarchive 10044 in the body.
You can then email your comments to 10044 AT debbugs.gnu.org in the normal way.

Toggle the display of automated, internal messages from the tracker.

View this report as an mbox folder, status mbox, maintainer mbox


Report forwarded to bug-gnu-emacs <at> gnu.org:
bug#10044; Package emacs,w32. (Mon, 14 Nov 2011 15:36:03 GMT) Full text and rfc822 format available.

Acknowledgement sent to Juanma Barranquero <lekktu <at> gmail.com>:
New bug report received and forwarded. Copy sent to bug-gnu-emacs <at> gnu.org. (Mon, 14 Nov 2011 15:36:03 GMT) Full text and rfc822 format available.

Message #5 received at submit <at> debbugs.gnu.org (full text, mbox):

From: Juanma Barranquero <lekktu <at> gmail.com>
To: Bug-Gnu-Emacs <bug-gnu-emacs <at> gnu.org>
Subject: "warning: reader_thread.SetEvent failed with 6 for fd -1" and
	accessing fd_info[-1]
Date: Mon, 14 Nov 2011 16:33:42 +0100
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 (;;)




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#10044; Package emacs,w32. (Mon, 14 Nov 2011 17:17:02 GMT) Full text and rfc822 format available.

Message #8 received at 10044 <at> debbugs.gnu.org (full text, mbox):

From: Eli Zaretskii <eliz <at> gnu.org>
To: Juanma Barranquero <lekktu <at> gmail.com>
Cc: 10044 <at> debbugs.gnu.org
Subject: Re: bug#10044: "warning: reader_thread.SetEvent failed with 6 for fd
	-1"	and accessing fd_info[-1]
Date: Mon, 14 Nov 2011 19:14:21 +0200
> From: Juanma Barranquero <lekktu <at> gmail.com>
> Date: Mon, 14 Nov 2011 16:33:42 +0100
> 
> 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 (;;)

Let's go for it, thanks.

Does this patch by chance solve a similar bogus DebPrint message each
time a versioned file under bzr control is visited?




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#10044; Package emacs,w32. (Mon, 14 Nov 2011 17:32:02 GMT) Full text and rfc822 format available.

Message #11 received at 10044 <at> debbugs.gnu.org (full text, mbox):

From: Juanma Barranquero <lekktu <at> gmail.com>
To: Eli Zaretskii <eliz <at> gnu.org>
Cc: 10044 <at> debbugs.gnu.org
Subject: Re: bug#10044: "warning: reader_thread.SetEvent failed with 6 for fd
	-1" and accessing fd_info[-1]
Date: Mon, 14 Nov 2011 18:30:00 +0100
On Mon, Nov 14, 2011 at 18:14, Eli Zaretskii <eliz <at> gnu.org> wrote:

> Let's go for it, thanks.

OK.

> Does this patch by chance solve a similar bogus DebPrint message each
> time a versioned file under bzr control is visited?

From a brief test, I'd say yes.

    Juanma




Reply sent to Juanma Barranquero <lekktu <at> gmail.com>:
You have taken responsibility. (Mon, 14 Nov 2011 17:55:02 GMT) Full text and rfc822 format available.

Notification sent to Juanma Barranquero <lekktu <at> gmail.com>:
bug acknowledged by developer. (Mon, 14 Nov 2011 17:55:02 GMT) Full text and rfc822 format available.

Message #16 received at 10044-done <at> debbugs.gnu.org (full text, mbox):

From: Juanma Barranquero <lekktu <at> gmail.com>
To: Eli Zaretskii <eliz <at> gnu.org>
Cc: 10044-done <at> debbugs.gnu.org
Subject: Re: bug#10044: "warning: reader_thread.SetEvent failed with 6 for fd
	-1" and accessing fd_info[-1]
Date: Mon, 14 Nov 2011 18:53:13 +0100
On Mon, Nov 14, 2011 at 18:30, Juanma Barranquero <lekktu <at> gmail.com> wrote:

>> Let's go for it, thanks.

Done, closing.




bug archived. Request was from Debbugs Internal Request <help-debbugs <at> gnu.org> to internal_control <at> debbugs.gnu.org. (Tue, 13 Dec 2011 12:24:02 GMT) Full text and rfc822 format available.

This bug report was last modified 12 years and 159 days ago.

Previous Next


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