Subject: Re: xset r rate -> memory fault
To: None <>
From: Jan Schaumann <>
List: tech-x11
Date: 03/01/2002 16:47:13
Content-Type: text/plain; charset=us-ascii
Content-Disposition: inline

[This is a re-send from my message to netbsd-users - it occurred to me
that tech-x11 might be interested/helpful in this matter]

Jan Schaumann <> wrote:
> Jan Schaumann <> wrote:
> > I'm puzzled by the fact that "xset r rate 500 30" gives me a
> > memory-fault (with core dump), but at the same time, if I start the X
> > server with "-ar1 500 -ar2 30" everything works as expected.
> > This is on an i386 with XFree86 Version
> FWIW, I found out that it works just fine with a new version of XFree86
> Version 4.1.0.  I haven't yet determined what the problem was exactly,
> though...

Ok, I take that back.  Things are (were) weird:  After upgrading
XFree86, the problem seemed to disappear for some instances, but
presisted in others.  AFAICT, the reason for "xset" to segfault was that
"xkbset_repeatrate" did not check the return-value from
"XkbGetKeyboard", assuming it would always get a proper value back.

In some instances (why, I have not yet been able to determine), the
function does however NOT return a pointer to the keyboard, and
naturally the next function-call segfaults.

I was able to fix the problem with the attached patch to
/usr/src/xsrc/xfree/xc/programs/xset/xset.c (that is, if no keyboard
pointer is returned, allocate a new one using defaults).

The curious thing is that this would indicate that the first call to
"XkbGetKeyboard" does not find the default keyboard (XkbUseCoreKbd),
while the second one does.  Two virtually identical machines (wrt to
configuration) showed different behaviour:  one always returned the
proper keyboard pointer, one didn't.  I yet have to track down why this

Anyway, maybe the attached patch will help somebody, otherwise:  It was
nice to have a conversation with myself.  To be continued... (?)


Please do not CC me when replying to messages on a Mailing List.
See Mail-Followup-To header (above) and

Content-Type: text/plain; charset=us-ascii
Content-Disposition: attachment; filename="xset.diff"

--- xset.c.orig Fri Mar  1 15:22:41 2002
+++ xset.c      Fri Mar  1 15:24:08 2002
@@ -1089,6 +1089,8 @@
 xkbset_repeatrate(Display *dpy, int delay, int interval)
   XkbDescPtr xkb = XkbGetKeyboard(dpy,XkbControlsMask,XkbUseCoreKbd);
+  if (!xkb)
+    xkb = XkbAllocKeyboard();
   XkbGetControls(dpy, XkbRepeatKeysMask, xkb);
   xkb->ctrls->repeat_delay = delay;
   xkb->ctrls->repeat_interval = interval;