Hi, folks. (Patricio Rojo may not hear any more. It was reported 3
years ago.) I'm Teika, a Sawfish developer.

Patricio Rojo wrote:
> I think it could be a very good idea to add "sawfish" 
> somewhere in that error line,
Absolutely. I'll soon fix it.

Neil, thank you very much for your fine analysis.

First, will it be possible for you to try the attached C patch? It
makes x-atom-name accept full 32-bit integer. If it works without your
patch, then it is the true solution. The precise Sawfish version
doesn't matter.

If not, ok, but I'd be glad if you let me ask some questions: 
1. Does it happen commonly to java applications, or specific to some?
   Is it reproducible with high probability? (Say, once a day or so.)
2. Which Java runtime (jre) do you use?
3. Is your architecture 32-bit?

As you noted, rep_INTP may cause overflow. An atom is a 32-bit
integer. In fact, rep's, uh, "primitive" integer, whose type predicate
is rep_INTP, is 30-bit or 62-bit, depending on the platform. Thus the
suspected bug is that for 31- or 32-bit integer argument on 32-bit
computer, x-atom-name wrongly throws error. But I've never seen this
error, nor can I trigger it.  (Mine is amd64 linux.)

32 bits? Yes. The too big number reported by Rojo,
18446744072353249216, is almost 2^64, may be a red herring; librep
BIGNUM printing may be broken, though not sure. (See
librep/src/numbers.c, rep_print_number_to_string().)

If yours is 64-bit too, it's nasty. It may be librep internal; related
Sawfish codes look ok after a browse, except x-atom-name. Rojo used
64 too, so this may be the case.

Unfortunately I don't understand well enough BIGNUM type in librep
which is complexly intertwined to other number types.

If mine doesn't help, then yours will be adopted. It's obscured, but
why not take a working one?

With best regards,
Teika (Teika kazura)
commit 1191a8274e298fe9727ba32b32faf66ac9a86894
Author: Teika kazura <[email protected]>
Date:   Mon May 10 14:57:46 2010 +0900

    x-atom-name accepts full 32 unsigned int. Previously only 30 bits are
    treated, if the architecture is 32-bit.

diff --git a/src/functions.c b/src/functions.c
index dfd0f4c..9ac860f 100644
--- a/src/functions.c
+++ b/src/functions.c
@@ -43,6 +43,7 @@
 #include "sawfish.h"
 #include <string.h>
 #include <X11/Xatom.h>
+#include <stdint.h>
 
 /* Number of outstanding server grabs made; only when this is zero is
    the server ungrabbed. */
@@ -922,8 +923,16 @@ Return the symbol with the same name as the X atom identified by the
 integer ATOM.
 ::end:: */
 {
-    rep_DECLARE1(atom, rep_INTP);
-    return x_atom_symbol (rep_INT(atom));
+  if(rep_INTP(atom)){
+    return x_atom_symbol(rep_INT(atom));
+  }
+  if(rep_INTEGERP(atom)){
+    return x_atom_symbol((uint32_t) rep_get_long_uint(atom));
+  }
+  /* This always returns an error. */
+  rep_DECLARE1(atom, rep_INTEGERP);
+  /* Just to make compiler silent. */
+  return Qnil;
 }
 
 DEFUN("root-window-id", Froot_window_id, Sroot_window_id, (void), rep_Subr0) /*

Reply via email to