* bug#10629: Infinite loop in emacs 23 on terminal (-nw option) on xgselect.c:58-59 when compiled with gtk+ or gconf support
[not found] <1327767888.1934.14.camel@localhost.localdomain>
@ 2012-01-28 17:01 ` Maciej Marcin Piechotka
2012-01-28 18:51 ` Glenn Morris
2012-01-28 18:46 ` bug#10631: Update of patch Maciej Marcin Piechotka
1 sibling, 1 reply; 4+ messages in thread
From: Maciej Marcin Piechotka @ 2012-01-28 17:01 UTC (permalink / raw
To: 10629
[-- Attachment #1.1: Type: text/plain, Size: 1007 bytes --]
On Sat, 2012-01-28 at 16:24 +0000, Maciej Marcin Piechotka wrote:
> I hit an infinite loop on gselect.c:58-59. After quick debugging I found
> that the problem is in loop xgselect.c:58-59:
>
> while(n_gfds > gfds_size)
> gfds_size *= 2;
>
> Problem is that:
>
> (gdb) p n_gfds
> $3 = 1
> (gdb) p gfds_size
> $4 = 0
>
> 1. It seems that xgselect_initialize was not called as X system is
> initialized.
>
> 2. Is there a reason why the code is not using (much more efficient but
> equivalent) such code in the first place:
>
> if (ngfds > gfds_size)
> {
> gfds_size = 1 << g_bit_storage (ngfds);
> xfree (gfds);
> gfds = xmalloc (sizeof (*gfds) * gfds_size);
> }
>
> 3. The attached file get rids of initialization at all initializing at
> the cost of conditional freeing of gfds (and starting mallocing from 1
> instead of 128).
>
> Best regards
>
Ups. Sorry - I forgot to add one file to git index. Corrected patch
attached.
Best regards
[-- Attachment #1.2: 0001-Fix-infinit-loop-when-emacs-is-compiled-with-GTK-sup.patch --]
[-- Type: text/x-patch, Size: 2091 bytes --]
From 3a06fc2b48eb7e55834d8e5e4adda1f2286758db Mon Sep 17 00:00:00 2001
From: Maciej Piechotka <uzytkownik2@gmail.com>
Date: Sat, 28 Jan 2012 16:12:45 +0000
Subject: [PATCH] Fix infinit loop when emacs is compiled with GTK+ support
and used in no-window mode
---
src/xgselect.c | 17 +++++------------
src/xgselect.h | 2 --
src/xterm.c | 2 --
3 files changed, 5 insertions(+), 16 deletions(-)
diff --git a/src/xgselect.c b/src/xgselect.c
index 333f7b1..4301eee 100644
--- a/src/xgselect.c
+++ b/src/xgselect.c
@@ -55,9 +55,11 @@ xg_select (max_fds, rfds, wfds, efds, timeout)
do {
if (n_gfds > gfds_size)
{
- while (n_gfds > gfds_size)
- gfds_size *= 2;
- xfree (gfds);
+ gfds_size = 1 << g_bit_storage (n_gfds);
+ if (gfds)
+ {
+ xfree (gfds);
+ }
gfds = xmalloc (sizeof (*gfds) * gfds_size);
}
@@ -152,14 +154,5 @@ xg_select (max_fds, rfds, wfds, efds, timeout)
}
#endif /* defined (USE_GTK) || defined (HAVE_GCONF) */
-void
-xgselect_initialize ()
-{
-#if defined (USE_GTK) || defined (HAVE_GCONF)
- gfds_size = 128;
- gfds = xmalloc (sizeof (*gfds)*gfds_size);
-#endif /* defined (USE_GTK) || defined (HAVE_GCONF) */
-}
-
/* arch-tag: c5873ee3-d1f6-44f9-9f3b-b14f70fd0e6a
(do not change this comment) */
diff --git a/src/xgselect.h b/src/xgselect.h
index 14488d6..3bb5428 100644
--- a/src/xgselect.h
+++ b/src/xgselect.h
@@ -30,8 +30,6 @@ extern int xg_select P_ ((int max_fds,
SELECT_TYPE *efds,
EMACS_TIME *timeout));
-extern void xgselect_initialize P_ ((void));
-
#endif /* XGSELECT_H */
/* arch-tag: 0c5392a8-3a41-41eb-839c-58e6595926f0
diff --git a/src/xterm.c b/src/xterm.c
index af8af50..83412ae 100644
--- a/src/xterm.c
+++ b/src/xterm.c
@@ -10989,8 +10989,6 @@ x_initialize ()
XSetIOErrorHandler (x_io_error_quitter);
signal (SIGPIPE, x_connection_signal);
-
- xgselect_initialize ();
}
--
1.7.8.4
[-- Attachment #2: This is a digitally signed message part --]
[-- Type: application/pgp-signature, Size: 836 bytes --]
^ permalink raw reply related [flat|nested] 4+ messages in thread
* bug#10631: Update of patch
[not found] <1327767888.1934.14.camel@localhost.localdomain>
2012-01-28 17:01 ` bug#10629: Infinite loop in emacs 23 on terminal (-nw option) on xgselect.c:58-59 when compiled with gtk+ or gconf support Maciej Marcin Piechotka
@ 2012-01-28 18:46 ` Maciej Marcin Piechotka
2012-01-28 19:04 ` Glenn Morris
1 sibling, 1 reply; 4+ messages in thread
From: Maciej Marcin Piechotka @ 2012-01-28 18:46 UTC (permalink / raw
To: 10631
[-- Attachment #1: Type: text/plain, Size: 78 bytes --]
Ups. Sorry - I forgot to add one file to git index. Corrected patch
attached.
[-- Attachment #2: 0001-Fix-infinit-loop-when-emacs-is-compiled-with-GTK-sup.patch --]
[-- Type: text/x-patch, Size: 2016 bytes --]
From 3a06fc2b48eb7e55834d8e5e4adda1f2286758db Mon Sep 17 00:00:00 2001
From: Maciej Piechotka <uzytkownik2@gmail.com>
Date: Sat, 28 Jan 2012 16:12:45 +0000
Subject: [PATCH] Fix infinit loop when emacs is compiled with GTK+ support
and used in no-window mode
---
src/xgselect.c | 17 +++++------------
src/xgselect.h | 2 --
src/xterm.c | 2 --
3 files changed, 5 insertions(+), 16 deletions(-)
diff --git a/src/xgselect.c b/src/xgselect.c
index 333f7b1..4301eee 100644
--- a/src/xgselect.c
+++ b/src/xgselect.c
@@ -55,9 +55,11 @@ xg_select (max_fds, rfds, wfds, efds, timeout)
do {
if (n_gfds > gfds_size)
{
- while (n_gfds > gfds_size)
- gfds_size *= 2;
- xfree (gfds);
+ gfds_size = 1 << g_bit_storage (n_gfds);
+ if (gfds)
+ {
+ xfree (gfds);
+ }
gfds = xmalloc (sizeof (*gfds) * gfds_size);
}
@@ -152,14 +154,5 @@ xg_select (max_fds, rfds, wfds, efds, timeout)
}
#endif /* defined (USE_GTK) || defined (HAVE_GCONF) */
-void
-xgselect_initialize ()
-{
-#if defined (USE_GTK) || defined (HAVE_GCONF)
- gfds_size = 128;
- gfds = xmalloc (sizeof (*gfds)*gfds_size);
-#endif /* defined (USE_GTK) || defined (HAVE_GCONF) */
-}
-
/* arch-tag: c5873ee3-d1f6-44f9-9f3b-b14f70fd0e6a
(do not change this comment) */
diff --git a/src/xgselect.h b/src/xgselect.h
index 14488d6..3bb5428 100644
--- a/src/xgselect.h
+++ b/src/xgselect.h
@@ -30,8 +30,6 @@ extern int xg_select P_ ((int max_fds,
SELECT_TYPE *efds,
EMACS_TIME *timeout));
-extern void xgselect_initialize P_ ((void));
-
#endif /* XGSELECT_H */
/* arch-tag: 0c5392a8-3a41-41eb-839c-58e6595926f0
diff --git a/src/xterm.c b/src/xterm.c
index af8af50..83412ae 100644
--- a/src/xterm.c
+++ b/src/xterm.c
@@ -10989,8 +10989,6 @@ x_initialize ()
XSetIOErrorHandler (x_io_error_quitter);
signal (SIGPIPE, x_connection_signal);
-
- xgselect_initialize ();
}
--
1.7.8.4
^ permalink raw reply related [flat|nested] 4+ messages in thread
* bug#10629: Infinite loop in emacs 23 on terminal (-nw option) on xgselect.c:58-59 when compiled with gtk+ or gconf support
2012-01-28 17:01 ` bug#10629: Infinite loop in emacs 23 on terminal (-nw option) on xgselect.c:58-59 when compiled with gtk+ or gconf support Maciej Marcin Piechotka
@ 2012-01-28 18:51 ` Glenn Morris
0 siblings, 0 replies; 4+ messages in thread
From: Glenn Morris @ 2012-01-28 18:51 UTC (permalink / raw
To: 10629; +Cc: Maciej Marcin Piechotka
This report is a literal duplicate of
http://debbugs.gnu.org/cgi/bugreport.cgi?bug=10631
and will be removed soon. Please direct any future correspondence on
this issue to 10631 AT debbugs.gnu.org.
^ permalink raw reply [flat|nested] 4+ messages in thread
* bug#10631: Update of patch
2012-01-28 18:46 ` bug#10631: Update of patch Maciej Marcin Piechotka
@ 2012-01-28 19:04 ` Glenn Morris
0 siblings, 0 replies; 4+ messages in thread
From: Glenn Morris @ 2012-01-28 19:04 UTC (permalink / raw
To: Maciej Marcin Piechotka; +Cc: 10631
Thanks for the report. This seems like a duplicate of
http://debbugs.gnu.org/cgi/bugreport.cgi?bug=9754
The same comments apply:
http://debbugs.gnu.org/cgi/bugreport.cgi?bug=9754#11
You can see the current xgselect.c at eg
http://bzr.savannah.gnu.org/lh/emacs/trunk/annotate/head:/src/xgselect.c
It would be great if you could test the 24.0.92 pretest from
http://alpha.gnu.org/gnu/emacs/pretest/
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2012-01-28 19:04 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
[not found] <1327767888.1934.14.camel@localhost.localdomain>
2012-01-28 17:01 ` bug#10629: Infinite loop in emacs 23 on terminal (-nw option) on xgselect.c:58-59 when compiled with gtk+ or gconf support Maciej Marcin Piechotka
2012-01-28 18:51 ` Glenn Morris
2012-01-28 18:46 ` bug#10631: Update of patch Maciej Marcin Piechotka
2012-01-28 19:04 ` Glenn Morris
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.