Bug 293209 (xrr-ubuntu)

Summary: Kwin crash on startup
Product: [Plasma] kwin Reporter: jcrosmer+0
Component: generalAssignee: KWin default assignee <kwin-bugs-null>
Status: RESOLVED UPSTREAM    
Severity: crash CC: antonis+kdebugs, asala, dreibh, edoubrayrie, emiel.kollof, epajarre, genimarca, iordan, jcrosmer+0, kde, kde, kdebugs, kmeaghermd, link, mail, mgoldshteyn, Michael_Feher, misc-kdeorg, pelucheloko, Ronny.Standtke, rtvd, twindragonsix, vikimaus, wim.entrop
Priority: NOR    
Version: unspecified   
Target Milestone: ---   
Platform: Ubuntu   
OS: Linux   
Latest Commit: Version Fixed In:
Sentry Crash Report:
Attachments: New crash information added by DrKonqi
New crash information added by DrKonqi
New crash information added by DrKonqi
New crash information added by DrKonqi

Description jcrosmer+0 2012-02-03 14:19:57 UTC
Application: kwin (4.7.3 (4.7.3))
KDE Platform Version: 4.7.3 (4.7.3)
Qt Version: 4.8.0
Operating System: Linux 3.2.0-6-generic x86_64
Distribution: Ubuntu precise (development branch)

-- Information about the crash:
- What I was doing when the application crashed:
I just logged into KDE.  Has happened the last few times I logged in.  The only special setting that might be relevant is a script that changes to 2-monitor setting because KDE doesn't remember this setting no matter what I do.  The script looks like:
xrandr --output VGA1 --pos 0x0 --mode 1920x1080 --refresh 60
xrandr --output HDMI1 --pos 1920x0 --mode 1920x1080 --refresh 60
xrandr --noprimary

The crash can be reproduced every time.

-- Backtrace:
Application: KWin (kwin), signal: Segmentation fault
Using host libthread_db library "/lib/x86_64-linux-gnu/libthread_db.so.1".
[Current thread is 1 (Thread 0x7f571e92f7a0 (LWP 1716))]

Thread 3 (Thread 0x7f5703710700 (LWP 1717)):
#0  0x00007f571e15a4d3 in select () at ../sysdeps/unix/syscall-template.S:82
#1  0x00007f571a5428e6 in qt_safe_select (nfds=14, fdread=0xcb8fc8, fdwrite=0xcb9260, fdexcept=0xcb94f8, orig_timeout=<optimized out>) at kernel/qcore_unix.cpp:83
#2  0x00007f571a547cf0 in QEventDispatcherUNIXPrivate::doSelect (this=0xcb8e10, flags=..., timeout=0x0) at kernel/qeventdispatcher_unix.cpp:223
#3  0x00007f571a5481f3 in QEventDispatcherUNIX::processEvents (this=0xcb8ab0, flags=...) at kernel/qeventdispatcher_unix.cpp:926
#4  0x00007f571a515202 in QEventLoop::processEvents (this=<optimized out>, flags=...) at kernel/qeventloop.cpp:149
#5  0x00007f571a515457 in QEventLoop::exec (this=0x7f570370fdb0, flags=...) at kernel/qeventloop.cpp:204
#6  0x00007f571a414f17 in QThread::exec (this=<optimized out>) at thread/qthread.cpp:501
#7  0x00007f571a4f4f9f in QInotifyFileSystemWatcherEngine::run (this=0xcb2220) at io/qfilesystemwatcher_inotify.cpp:248
#8  0x00007f571a417f3b in QThreadPrivate::start (arg=0xcb2220) at thread/qthread_unix.cpp:298
#9  0x00007f57143d5e2b in start_thread (arg=0x7f5703710700) at pthread_create.c:304
#10 0x00007f571e1610dd in clone () at ../sysdeps/unix/sysv/linux/x86_64/clone.S:112
#11 0x0000000000000000 in ?? ()

Thread 2 (Thread 0x7f5702f0f700 (LWP 1718)):
#0  pthread_cond_wait@@GLIBC_2.3.2 () at ../nptl/sysdeps/unix/sysv/linux/x86_64/pthread_cond_wait.S:162
#1  0x00007f571cfba1f2 in ?? () from /usr/lib/x86_64-linux-gnu/libQtScript.so.4
#2  0x00007f571cfba229 in ?? () from /usr/lib/x86_64-linux-gnu/libQtScript.so.4
#3  0x00007f57143d5e2b in start_thread (arg=0x7f5702f0f700) at pthread_create.c:304
#4  0x00007f571e1610dd in clone () at ../sysdeps/unix/sysv/linux/x86_64/clone.S:112
#5  0x0000000000000000 in ?? ()

Thread 1 (Thread 0x7f571e92f7a0 (LWP 1716)):
[KCrash Handler]
#6  __GI___libc_free (mem=0x1) at malloc.c:3709
#7  0x00007f571be8a769 in XFree () from /usr/lib/x86_64-linux-gnu/libX11.so.6
#8  0x00007f571b7d42ee in XRRUpdateConfiguration () from /usr/lib/x86_64-linux-gnu/libXrandr.so.2
#9  0x00007f571e49d3b2 in ?? () from /usr/lib/kde4/libkdeinit/libkdeinit4_kwin.so
#10 0x00007f571e478558 in ?? () from /usr/lib/kde4/libkdeinit/libkdeinit4_kwin.so
#11 0x00007f57199088d5 in qt_x11EventFilter (ev=0x7fff9370a9a0) at kernel/qapplication_x11.cpp:440
#12 qt_x11EventFilter (ev=0x7fff9370a9a0) at kernel/qapplication_x11.cpp:428
#13 0x00007f5719917cb8 in QApplication::x11ProcessEvent (this=0x7fff9370acb0, event=0x7fff9370a9a0) at kernel/qapplication_x11.cpp:3438
#14 0x00007f5719941f3a in QEventDispatcherX11::processEvents (this=0x81ead0, flags=...) at kernel/qeventdispatcher_x11.cpp:132
#15 0x00007f571a515202 in QEventLoop::processEvents (this=<optimized out>, flags=...) at kernel/qeventloop.cpp:149
#16 0x00007f571a515457 in QEventLoop::exec (this=0x7fff9370abf0, flags=...) at kernel/qeventloop.cpp:204
#17 0x00007f571a51a4e7 in QCoreApplication::exec () at kernel/qcoreapplication.cpp:1148
#18 0x00007f571e47aca6 in kdemain () from /usr/lib/kde4/libkdeinit/libkdeinit4_kwin.so
#19 0x00007f571e09e30d in __libc_start_main (main=0x400640, argc=3, ubp_av=0x7fff9370b318, init=<optimized out>, fini=<optimized out>, rtld_fini=<optimized out>, stack_end=0x7fff9370b308) at libc-start.c:226
#20 0x0000000000400671 in _start ()

Reported using DrKonqi
Comment 1 Thomas Lübking 2012-02-03 15:20:31 UTC
memory corruption, crashes in xrandr - try to add a "sleep 1" between the xrandr calls in your script.

if your sleep version is nifty enough, you can probably use smaller values than a second which should be sufficient as well.

otherwise try whether
xrandr --output VGA1 --pos 0x0 --mode 1920x1080 --output HDMI1 --pos 1920x0 --mode 1920x1080  --noprimary
works
Comment 2 Thomas Lübking 2012-02-08 17:52:31 UTC
*** Bug 293648 has been marked as a duplicate of this bug. ***
Comment 3 Bzzz 2012-02-08 17:59:20 UTC
Thanks for marking my report as a duplicate of this one.
In my case, this happens only for remote logins (every time), not for local login.
Comment 4 jcrosmer+0 2012-02-14 14:23:37 UTC
Kwin crashes on even this simple xrandr invocation:
xrandr --output HDMI1 --pos 1920x0

Even if this is a problem with xrandr, maybe kwin should still handle it more gracefully than crashing.  Would be great if I could use a dual monitor setup with KDE without getting crashes every time I start up.
Comment 5 Thomas Lübking 2012-02-14 15:26:14 UTC
(In reply to comment #4)
> Kwin crashes on even this simple xrandr invocation:
> xrandr --output HDMI1 --pos 1920x0
Does it only happen for the HDMI device and/or only for the position adjustment?

> Even if this is a problem with xrandr, maybe kwin should still handle it more
> gracefully than crashing. 
It's not a problem with the cli tool but with the extension, ie libXrandr - or one of its deps (libX11, libc)
Whenever you find a way to avoid segfaults in sublying library calls:
DO NOT TELL ANYONE!
Write a book and sell it. You'll become a millionaire ;-)

> Would be great if I could use a dual monitor setup with KDE without getting crashes every time I start up.

- Get an update for libXRandr, libX11 or libc (though this may also be just a downstream issue, ie. a wonky patch from your distro. The only two reports are from the very same distro & version)
- Try to deactivate "Display Management change Monitor" in "kcmshell4 kded" (but that is just a wild guess about timing, i doubt it solves anything)
Comment 6 tim blechmann 2012-03-31 09:39:48 UTC
Created attachment 70035 [details]
New crash information added by DrKonqi

kwin (4.8.1 (4.8.1)) on KDE Platform 4.8.1 (4.8.1) using Qt 4.8.0

- What I was doing when the application crashed:

after upgrading to ubuntu 12.04 beta 2, i've experienced this crash at startup

-- Backtrace (Reduced):
#6  __GI___libc_free (mem=0x1) at malloc.c:2968
[...]
#8  0x00007ff29bbc5819 in XFree () from /usr/lib/x86_64-linux-gnu/libX11.so.6
#9  0x00007ff29b76d2ee in XRRUpdateConfiguration () from /usr/lib/x86_64-linux-gnu/libXrandr.so.2
#10 0x00007ff29e4b8750 in KWin::Workspace::workspaceEvent (this=0x24d5720, e=0x7fffc9b67000) at ../../kwin/events.cpp:460
#11 0x00007ff29e4a9fa8 in KWin::Application::x11EventFilter (this=0x7fffc9b67310, e=0x7fffc9b67000) at ../../kwin/main.cpp:359
Comment 7 Martin Flöser 2012-04-17 16:07:08 UTC
*** Bug 298304 has been marked as a duplicate of this bug. ***
Comment 8 Martin Flöser 2012-04-18 18:56:23 UTC
*** Bug 298370 has been marked as a duplicate of this bug. ***
Comment 9 iordan 2012-04-18 19:36:19 UTC
Hi Martin,

Can you please tell me what package has this bug been resolved in upstream? I would like to try upgrading something on my system to a fixed version and to ensure that the bug has disappeared. We are in desperate need to get kwin working under NX and are willing to actively help with testing!

Is there a possible workaround for this bug? I am not running xrandr myself, so would I have to try an updated libXrandr.so.2?

Thanks!
Iordan
Comment 10 Thomas Lübking 2012-04-18 19:55:36 UTC
(In reply to comment #9)
> Can you please tell me what package has this bug been resolved in upstream?
"resolved upstream" actually just means "bug in used library, not our problem"
afaics however only ubuntu and only this very version seems affected, what could point a downstream (bad distro patch) bug
Comment 11 iordan 2012-04-19 17:35:51 UTC
OK, I've reported this bug to Ubuntu as well. Anybody who is affected should also go and raise the heat on the bug (say that you are affected or create duplicate bugs) if you are desperate to fix this.

Here is a link to my bug-report:
https://bugs.launchpad.net/ubuntu/+source/libx11/+bug/985202
Comment 12 Thomas Lübking 2012-04-26 10:10:51 UTC
*** Bug 298845 has been marked as a duplicate of this bug. ***
Comment 13 Martin Flöser 2012-05-10 09:04:12 UTC
*** Bug 299728 has been marked as a duplicate of this bug. ***
Comment 14 Thomas Lübking 2012-05-17 05:57:24 UTC
*** Bug 300174 has been marked as a duplicate of this bug. ***
Comment 15 Thomas Lübking 2012-05-18 09:57:39 UTC
*** Bug 300234 has been marked as a duplicate of this bug. ***
Comment 16 Thomas Lübking 2012-05-23 18:21:40 UTC
*** Bug 300515 has been marked as a duplicate of this bug. ***
Comment 17 Martin Flöser 2012-06-07 18:34:44 UTC
*** Bug 301388 has been marked as a duplicate of this bug. ***
Comment 18 Thomas Lübking 2012-06-21 12:31:11 UTC
*** Bug 302191 has been marked as a duplicate of this bug. ***
Comment 19 Bahh 2012-07-19 01:58:31 UTC
Created attachment 72617 [details]
New crash information added by DrKonqi

kwin (4.8.4 (4.8.4)) on KDE Platform 4.8.4 (4.8.4) using Qt 4.8.1

- What I was doing when the application crashed:

Brand new install of Kubuntu 12.04.  Same behavior as others, Kwin crashes right after a new NX session is opened.

-- Backtrace (Reduced):
#8  0xb67c4f9b in XFree (data=0x1) at ../../src/XlibInt.c:1701
#9  0xb6771c76 in XRRUpdateConfiguration (event=0xbfeec42c) at ../../src/Xrandr.c:446
#10 0xb76585c7 in KWin::Workspace::workspaceEvent (this=0x891e430, e=0xbfeec42c) at ../../kwin/events.cpp:460
#11 0xb7648842 in KWin::Application::x11EventFilter (this=0xbfeec678, e=0xbfeec42c) at ../../kwin/main.cpp:359
#12 0xb54cf534 in qt_x11EventFilter (ev=0xbfeec42c) at kernel/qapplication_x11.cpp:441
Comment 20 Ronny Standtke 2012-08-21 20:34:31 UTC
Created attachment 73372 [details]
New crash information added by DrKonqi

kwin (4.9.00) on KDE Platform 4.9.00 using Qt 4.8.1

I just run into a similar crash while logging in to my desktop via an X11 thin client.

-- Backtrace (Reduced):
#6  mUSABLe (mem=0x1) at malloc.c:4651
#7  __malloc_usable_size (m=0x1) at malloc.c:3379
[...]
#10 0x00007f335399d819 in XFree (data=<optimized out>) at ../../src/XlibInt.c:1701
#11 0x00007f33535452ee in XRRUpdateConfiguration (event=0x7fffce3726d0) at ../../src/Xrandr.c:446
#12 0x00007f3355c53736 in KWin::Workspace::workspaceEvent (this=0x1f6ed80, e=0x7fffce3726d0) at ../../kwin/events.cpp:461
Comment 21 Christoph Feck 2012-09-19 14:40:01 UTC
*** Bug 307023 has been marked as a duplicate of this bug. ***
Comment 22 Thomas Lübking 2012-10-01 15:46:33 UTC
*** Bug 307675 has been marked as a duplicate of this bug. ***
Comment 23 Thomas Lübking 2012-10-17 11:40:38 UTC
*** Bug 308535 has been marked as a duplicate of this bug. ***
Comment 24 Martin Flöser 2012-10-30 20:38:04 UTC
*** Bug 309268 has been marked as a duplicate of this bug. ***
Comment 25 Thomas Lübking 2012-11-14 20:09:01 UTC
*** Bug 310115 has been marked as a duplicate of this bug. ***
Comment 26 geni 2013-01-04 15:53:13 UTC
Created attachment 76184 [details]
New crash information added by DrKonqi

kwin (4.9.5) on KDE Platform 4.9.5 using Qt 4.8.2

- What I was doing when the application crashed:
 
I  started the NX session and KWin crashed.

-- Backtrace (Reduced):
#6  mUSABLe (mem=0x1) at malloc.c:4651
#7  __malloc_usable_size (m=0x1) at malloc.c:3379
[...]
#10 0x00007f61b52ab819 in XFree () from /usr/lib/x86_64-linux-gnu/libX11.so.6
#11 0x00007f61b4e532ee in XRRUpdateConfiguration () from /usr/lib/x86_64-linux-gnu/libXrandr.so.2
[...]
#14 0x00007f61b2181aa5 in qt_x11EventFilter (ev=0x7fff48df4f70) at kernel/qapplication_x11.cpp:441
Comment 27 Denys 2013-01-24 05:31:59 UTC
Is this bug really resolved? If so, in which version of KDE was it done?
Comment 28 Martin Flöser 2013-01-24 06:46:36 UTC
(In reply to comment #27)
> Is this bug really resolved? If so, in which version of KDE was it done?
Please see comment #10
Comment 29 Martin Flöser 2013-02-19 13:30:46 UTC
*** Bug 315450 has been marked as a duplicate of this bug. ***
Comment 30 Thomas Lübking 2013-02-19 14:05:49 UTC
last dupe is OpenSuSE - no more ubuntu-only issue
Comment 31 Martin Flöser 2013-02-19 14:22:40 UTC
> last dupe is OpenSuSE - no more ubuntu-only issue
and it's the 12.3 release to get out quite soon. Seems like they updated the 
library...
Comment 32 Thomas Lübking 2013-02-19 14:50:32 UTC
... Unlikely being libxrandr then - bug appeard between 11.10 and 12.04 in ubuntu - both shipping 1.3.2 while current 12.10 has 1.4.0

SuSE 12.2 had 1.3.2 as well.

And Arch is on 1.4.0 since 2012-07-29

The suse trace however has lines. gonna check them tonight ;-)
Comment 33 Thomas Lübking 2013-02-19 20:56:45 UTC
Anybody who
- can cause this for sure
- can compile and test a patch

please raise hands.
Comment 34 kde 2013-02-19 21:07:14 UTC
I can reproduce this 100% of the time on Kubuntu 12.10 (before 12.04). It happens every time I connect to my machine via NX client and also once connected every time I change with the NX window resolution (e.g. do fullscreen). I you can help me with the compile part (haven't compile kde before) I can test.
Comment 35 Thomas Lübking 2013-02-19 21:17:40 UTC
(In reply to comment #34)
> haven't compile kde before

Thanks alot. Let's first see whether someone who can "just do" pops up, otherwise you'll learn how to compile ;-)
Comment 36 Andreas Kuhl 2013-02-20 06:04:57 UTC
I can both trigger this and compile KDE. At your service... :-)
Comment 37 Thomas Lübking 2013-02-20 12:10:47 UTC
Ok, patch is possibly trivial:
in events.cpp, find XRRUpdateConfiguration(e); (~line 468) and inject

XSync(display(), false);

right after.

I'll explain the guess if it works =)
Comment 38 Andreas Kuhl 2013-02-20 13:09:23 UTC
Patched the file:

--------------------
diff --git a/kwin/events.cpp b/kwin/events.cpp
index 281f9e7..f5492e7 100644
--- a/kwin/events.cpp
+++ b/kwin/events.cpp
@@ -462,6 +462,7 @@ bool Workspace::workspaceEvent(XEvent * e)
     default:
         if (e->type == Extensions::randrNotifyEvent() && Extensions::randrAvailable()) {
             XRRUpdateConfiguration(e);
+           XSync(display(),false);
             if (compositing()) {
                 // desktopResized() should take care of when the size or
                 // shape of the desktop has changed, but we also want to
--------------------

Then cmake, make and make install. Afterwards kwin --replace.

Unfortunally, KWin stills crashes when unplugging:

--------------------

Application: KWin (kwin), signal: Segmentation fault
Using host libthread_db library "/lib64/libthread_db.so.1".
[Current thread is 1 (Thread 0x7f16586f5780 (LWP 15862))]

Thread 3 (Thread 0x7f1636ffd700 (LWP 15891)):
#0  0x00007f1652b1a964 in pthread_cond_wait@@GLIBC_2.3.2 () from /lib64/libpthread.so.0
#1  0x00007f16549c7307 in QTWTF::TCMalloc_PageHeap::scavengerThread (this=0x7f1654cd4660 <QTWTF::pageheap_memory>) at ../3rdparty/javascriptcore/JavaScriptCore/wtf/FastMalloc.cpp:2359
#2  0x00007f16549c7339 in QTWTF::TCMalloc_PageHeap::runScavengerThread (context=<optimized out>) at ../3rdparty/javascriptcore/JavaScriptCore/wtf/FastMalloc.cpp:1464
#3  0x00007f1652b16e0f in start_thread () from /lib64/libpthread.so.0
#4  0x00007f1650ab77dd in clone () from /lib64/libc.so.6

Thread 2 (Thread 0x7f162ffff700 (LWP 15893)):
#0  0x00007f1652b1a964 in pthread_cond_wait@@GLIBC_2.3.2 () from /lib64/libpthread.so.0
#1  0x00007f16349b7543 in ?? () from /usr/lib64/dri/r600_dri.so
#2  0x00007f1652b16e0f in start_thread () from /lib64/libpthread.so.0
#3  0x00007f1650ab77dd in clone () from /lib64/libc.so.6

Thread 1 (Thread 0x7f16586f5780 (LWP 15862)):
[KCrash Handler]
#5  0x00007f1650a4d634 in free () from /lib64/libc.so.6
#6  0x00007f1656bc3089 in XFree (data=<optimized out>) at XlibInt.c:1701
#7  0x00007f1655f2fad6 in XRRUpdateConfiguration (event=<optimized out>) at Xrandr.c:509
#8  0x00007f165824c998 in KWin::Workspace::workspaceEvent (this=0xa3a8e0, e=0x7fffe2452380) at /home/ademmer/Source/own/KDE/kde-workspace/kwin/events.cpp:464
#9  0x00007f165823e2e8 in KWin::Application::x11EventFilter (this=0x7fffe24528e0, e=0x7fffe2452380) at /home/ademmer/Source/own/KDE/kde-workspace/kwin/main.cpp:362
#10 0x00007f16520a2bfc in qt_x11EventFilter (ev=0x7fffe2452380) at kernel/qapplication_x11.cpp:435
#11 qt_x11EventFilter (ev=0x7fffe2452380) at kernel/qapplication_x11.cpp:423
#12 0x00007f16520b01eb in QApplication::x11ProcessEvent (this=0x7fffe24528e0, event=0x7fffe2452380) at kernel/qapplication_x11.cpp:3362
#13 0x00007f16520d79d9 in QEventDispatcherX11::processEvents (this=0x8b8fe0, flags=...) at kernel/qeventdispatcher_x11.cpp:132
#14 0x00007f1652ea79bf in QEventLoop::processEvents (this=this@entry=0x7fffe24525f0, flags=...) at kernel/qeventloop.cpp:149
#15 0x00007f1652ea7c48 in QEventLoop::exec (this=0x7fffe24525f0, flags=...) at kernel/qeventloop.cpp:204
#16 0x00007f1652eac8e8 in QCoreApplication::exec () at kernel/qcoreapplication.cpp:1218
#17 0x00007f165824089a in kdemain (argc=3, argv=0x7fffe2452a28) at /home/ademmer/Source/own/KDE/kde-workspace/kwin/main.cpp:537
#18 0x00007f16509f0a15 in __libc_start_main () from /lib64/libc.so.6
#19 0x00000000004009c1 in _start () at ../sysdeps/x86_64/start.S:123
Comment 39 Andreas Kuhl 2013-02-20 14:21:37 UTC
One clarification: My original bug report (Bug 309268) told that the crashes would appear both on plugging and unplugging. In fact, I am only to trigger the crash on unplugging an external display.
Comment 40 Thomas Lübking 2013-02-20 19:00:08 UTC
blast.

+           XSync(display(),false); // voodoo
+           if (qApp->desktop()->screenCount()) // possible cause
                XRRUpdateConfiguration(e);
+           XSync(display(),false); // because xrandr states "should do that"

but that should crash before (in xrandr) so i do not really believe it's gonna work (unless the source lines are padded in your compilation)
Comment 41 Andreas Kuhl 2013-02-21 07:54:35 UTC
Not sure whether I got this right...

------------

diff --git a/kwin/events.cpp b/kwin/events.cpp
index 281f9e7..05cecc3 100644
--- a/kwin/events.cpp
+++ b/kwin/events.cpp
@@ -461,7 +461,10 @@ bool Workspace::workspaceEvent(XEvent * e)
         break;
     default:
         if (e->type == Extensions::randrNotifyEvent() && Extensions::randrAvailable()) {
-            XRRUpdateConfiguration(e);
+           XSync(display(),false);
+           if (qApp->desktop()->screenCount()) // possible cause
+               XRRUpdateConfiguration(e);
+           XSync(display(),false); // because xrandr states "should do that"
             if (compositing()) {
                 // desktopResized() should take care of when the size or
                 // shape of the desktop has changed, but we also want to

------------

Was this your suggestion? Still crashing on unplug though... :(
Comment 42 Martin Flöser 2013-02-27 10:35:27 UTC
*** Bug 315840 has been marked as a duplicate of this bug. ***
Comment 43 Thomas Lübking 2013-03-15 21:37:13 UTC
*** Bug 316800 has been marked as a duplicate of this bug. ***
Comment 44 Thomas Lübking 2013-03-15 21:43:07 UTC
Hello fedora.
Xrandr portion crashing is btw:

    /*
     * so the next time someone wants some data, it will be fetched;
     * it might be better to force the round trip immediately, but
     * I dislike pounding the server simultaneously when not necessary
     */
    if (xrri->config[snum] != NULL) {
	XFree (xrri->config[snum]);
^^^^^^^^^^^^^^^^^^^^^^^^^ <-  this line
	xrri->config[snum] = NULL;
    }