unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
From: Glenn Morris <rgm@gnu.org>
To: 9754@debbugs.gnu.org
Cc: Ryan Lortie <desrt@desrt.ca>
Subject: bug#9754: emacs -nv fails on glib 2.31
Date: Fri, 14 Oct 2011 13:48:06 -0400	[thread overview]
Message-ID: <6zwrc7h3c9.fsf@fencepost.gnu.org> (raw)
In-Reply-To: <1318609098.30586.7.camel@moonpix.lan> (Ryan Lortie's message of "Fri, 14 Oct 2011 12:18:18 -0400")


[ I am resending this report, which was assigned to the wrong package
due to a "Packages:"/"Package:" typo, so that it appears on the
bug-gnu-emacs list .]

From: Ryan Lortie
Packages: emacs
Version: 23.3

When running "emacs -nw" with the latest glib version, emacs gets stuck
in this infinite loop:

in xg_select at /usr/src/debug/emacs-23.3/src/xgselect.c:59

58	        while (n_gfds > gfds_size) 
59	          gfds_size *= 2;

This code is buggy in the case that gfds_size is zero (since clearly, no
matter how many times you multiply by 2, you're not going to increase
it).

Further down in the same file, you see:

155	void
156	xgselect_initialize ()
157	{
158	#if defined (USE_GTK) || defined (HAVE_GCONF)
159	  gfds_size = 128;
160	  gfds = xmalloc (sizeof (*gfds)*gfds_size);


So it's clear that xgselect_initialize() is not being called in the
"-nw" case.  That makes sense -- why initialise GTK when not using it?

The problem is that xg_select() is used even in the "-nw" case, without
_initialize() having been called.  This worked before because an unused
GMainContext used to have 0 fds in it, so n_gfds would be zero and
gfds_size would not need to be increased, causing the bug to be skipped
over.

Recent changes in glib have introduced one fd to every GMainContext to
deal with the inherent race introduced by signal delivery (closing a
longstanding glib bug).  This means that the untouched GMainContext no
longer has 0 fds -- but 1.  This is what is triggering the problem in
the buggy code above.


The solution to this problem is one of:

 - ensure xgselect_initialize() is always called
 - don't use xg_select in -nw case
 - fix the code to deal with the array being zero-sized and nuke
   xgselect_initialize()





  parent reply	other threads:[~2011-10-14 17:48 UTC|newest]

Thread overview: 31+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <CABhPDt8f1iNs0+1N6Rn-8VbRPcscvbAda9KB388AzphWj4s_QA@mail.gmail.com>
     [not found] ` <4FAC34DA.7040606@cs.ucla.edu>
2012-05-15 19:08   ` bug#9754: Issue with Emacs 23.4 Ken Brown
2012-05-15 21:51     ` Paul Eggert
2012-05-15 22:28       ` Ken Brown
2012-05-16  2:23         ` Stefan Monnier
2012-05-16  6:42           ` Michael Albinus
     [not found]           ` <1318609098.30586.7.camel@moonpix.lan>
2011-10-14 17:48             ` Glenn Morris [this message]
2011-10-16  5:15             ` bug#9754: emacs -nv fails on glib 2.31 Paul Eggert
2011-11-11 12:32             ` Olivier Blin
2011-11-11 17:16               ` Glenn Morris
2012-01-28 21:14             ` Ulrich Mueller
2012-05-16 17:39             ` bug#9754: Issue with Emacs 23.4 Achim Gratz
2012-05-17  1:19               ` Stefan Monnier
2012-05-17 11:04                 ` Ken Brown
2012-05-17 12:43                   ` Ken Brown
2012-05-17 12:49                     ` Andreas Schwab
2012-05-17 13:20                       ` Ken Brown
2012-05-17 14:01                         ` Andreas Schwab
2012-05-17 15:02                     ` Stefan Monnier
2012-05-17 18:26                       ` Ken Brown
2012-05-18 16:33                         ` Glenn Morris
2012-05-18 17:09                           ` Ken Brown
2012-05-19  6:30                             ` Glenn Morris
2012-05-19 12:38                               ` Ken Brown
2012-05-18 18:02                         ` Stefan Monnier
2012-05-18 18:38                           ` Ken Brown
2012-05-18 19:12                             ` Paul Eggert
2012-05-18 20:04                               ` Ken Brown
2012-05-19 21:56                                 ` Ken Brown
2012-05-25 20:32                                   ` Ken Brown
2012-05-17  6:24             ` Achim Gratz
2012-05-16  2:28         ` Paul Eggert

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=6zwrc7h3c9.fsf@fencepost.gnu.org \
    --to=rgm@gnu.org \
    --cc=9754@debbugs.gnu.org \
    --cc=desrt@desrt.ca \
    /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).