After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 139158 - gimp-remote complains about $DISPLAY and fails
gimp-remote complains about $DISPLAY and fails
Status: RESOLVED FIXED
Product: GIMP
Classification: Other
Component: General
2.0.x
Other Linux
: Normal normal
: 2.0
Assigned To: GIMP Bugs
GIMP Bugs
Depends on:
Blocks:
 
 
Reported: 2004-04-05 17:07 UTC by peppelorum
Modified: 2004-04-13 16:53 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
gimp-remote.patch (1.13 KB, patch)
2004-04-08 13:48 UTC, Stanislav Brabec
none Details | Review
gimp-remote-sleep.patch (790 bytes, patch)
2004-04-08 16:02 UTC, Stanislav Brabec
none Details | Review
close the X display before calling exec() (2.94 KB, patch)
2004-04-09 13:59 UTC, Sven Neumann
none Details | Review
updated patch using gdk_display_close() (2.02 KB, patch)
2004-04-09 16:36 UTC, Sven Neumann
none Details | Review
patch against gimp-2.0.0 using XCloseDisplay() (2.04 KB, patch)
2004-04-09 17:10 UTC, Sven Neumann
none Details | Review

Description peppelorum 2004-04-05 17:07:15 UTC
Tried to use gimp-remote-2.0 with the following command 
'gimp-remote-2.0 /yada/blat.xcf' but that results in the following message: 
Xlib: connection to ":0.0" refused by server 
Xlib: XDM authorization key matches an existing client! 
GIMP could not initialize the graphical user interface. 
Make sure a proper setup for your display environment exists. 
 
Checked the DISPLAY an it shows ':0.0' 
Then I tried to start it with 'gimp-remote-2.0 --display=:0.0 /yada/blat.xcf' 
but I got the same answer. 
 
I use the packaged version of Gimp avalible from Debian/unstable
Comment 1 Sven Neumann 2004-04-05 17:31:31 UTC
That's an authentication problem with your X-server then. Can you start gimp-2.0
from this console? It will probably fail with the same error message.
Comment 2 Stanislav Brabec 2004-04-07 10:32:33 UTC
Some of our testers are able to reproduce this bug.

gimp starts without problems on these machines.

There is very old mail discussing the same.

http://www.mail-archive.com/lyx-users@lists.lyx.org/msg14443.html
Comment 3 Stanislav Brabec 2004-04-07 12:45:21 UTC
Additional note:

When using gdm, which doesn't set XDM-AUTHORIZATION-1, it works fine.
Comment 4 Stanislav Brabec 2004-04-07 14:53:35 UTC
Additional info from SuSE Bugzilla:

Additional Comment #21 From Michael Matz  2004-04-07 16:30

I know what happens.  gimp-remote-2.0 tries to send the cookie twice.  Or 
better said it sends the cookie, then execve's gimp, and that one also sends 
the cookie (still same PID!).  This happens because the display is opened 
twice.  Now the cookie is uniquified before sending, with time(), and probably 
PID.  _If_ the two cookie sendings happen in the same second the same string 
will be send and the server correctly notices that this already is there. 
And because this all is fairly fast (on my machine on 0.09 seconds difference)  
the two sends only very seldomly happen at different time. 
Comment 5 Stanislav Brabec 2004-04-08 13:48:19 UTC
Created attachment 26469 [details] [review]
gimp-remote.patch

Patch from Michael Matz <matz@suse.de>.
Comment 6 Sven Neumann 2004-04-08 15:11:37 UTC
I am afraid this change will break startup notification because of the PID change.
Comment 7 Sven Neumann 2004-04-08 15:20:41 UTC
Did some testing and everything seems to run fine. The only way to find out if
it works for everyone else is to get the change into 2.0.1. So I have now
applied the patch:

2004-04-08  Sven Neumann  <sven@gimp.org>

	* tools/gimp-remote.c (start_new_gimp): applied a patch from
	Michael Matz that calls fork() before starting gimp. This is to
	avoid X server authentification problems (bug #139158).
Comment 8 Stanislav Brabec 2004-04-08 16:01:59 UTC
Additional info from SuSE Bugzilla:

Additional Comment #30 From Michael Matz  2004-04-08 17:54

Crap.  Without a real fix in libX11 (in ConnDis.c:GetAuthorization) to make 
the unique members more finegraned the only thing left would be to ensure 
that the gimp executable actually is started after the current second 
finished. 
 
The simplest thing would be to add a sleep(1) .  Ugly, but ... 

Additional Comment #31 From Michael Matz 2004-04-08 17:56

Created an attachment (id=10175)
2. Patch for gimp-remote.c (using sleep)

Like in this patch.  Also tested locally (i.e. without rebuilding the package)
Comment 9 Stanislav Brabec 2004-04-08 16:02:54 UTC
Created attachment 26479 [details] [review]
gimp-remote-sleep.patch
Comment 10 Sven Neumann 2004-04-08 16:11:38 UTC
Are you saying the first patch you attached does not work? I have committed it
in the meantime.
Comment 11 Stanislav Brabec 2004-04-08 16:17:45 UTC
First patch does work and fixes the problem. But can have problems with startup
notification. This new one should not have problems, but adds 1sec delay. I
don't know, what is better.
Comment 12 Stanislav Brabec 2004-04-08 16:26:53 UTC
Maybe better idea - don't fork before calling GIMP, but fork before initializing
Xlib inside gimp-remote.

If this fork will succeed, you have free key for gdk_notify_startup_complete().
If this fork will fail, you have free key for exec GIMP.
Comment 13 Manish Singh 2004-04-08 18:24:46 UTC
I don't like forking at all. Wouldn't it be enough to simply close the display
before the exec?
Comment 14 Raphaël Quinet 2004-04-09 11:11:23 UTC
Yosh is right: if it is enough to close the connection to the X server before the
exec, that would be a better solution.
Comment 15 Sven Neumann 2004-04-09 12:34:41 UTC
Only that there's no GTK+ API to do that. But we can copy _gdk_windowing_exit().
I will come up with such a patch later.
Comment 16 Sven Neumann 2004-04-09 13:59:29 UTC
Created attachment 26525 [details] [review]
close the X display before calling exec()
Comment 17 Sven Neumann 2004-04-09 14:00:07 UTC
I could not reproduce the problem, so I cannot test this. I would appreciate
feedback on the patch that I just attached.
Comment 18 Manish Singh 2004-04-09 16:30:33 UTC
Hm, gdk_display_close() would do the job, no?
Comment 19 Sven Neumann 2004-04-09 16:35:20 UTC
Yes, of course. No idea why I did not find that. Updated patch will follow.
Comment 20 Sven Neumann 2004-04-09 16:36:44 UTC
Created attachment 26533 [details] [review]
updated patch using gdk_display_close()
Comment 21 Manish Singh 2004-04-09 16:50:09 UTC
Argh, _gdk_windowing_set_default_display is buggy and causes a crash when used
like above. Guess it's best to use Sven's previous patch with XCloseDisplay
explictly if that solves this for people.
Comment 22 Sven Neumann 2004-04-09 17:10:42 UTC
Created attachment 26534 [details] [review]
patch against gimp-2.0.0 using XCloseDisplay()
Comment 23 Ari Pollak 2004-04-10 03:51:58 UTC
any objections to me including this patch in the Debian gimp package?
Comment 24 Ari Pollak 2004-04-10 03:53:19 UTC
Oh, and Debian bug tracking this:
http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=109344
Comment 25 Sven Neumann 2004-04-10 09:58:27 UTC
The patch will be in 2.0.1 which is supposed to be released today to tomorrow.
Comment 26 Sven Neumann 2004-04-10 10:27:25 UTC
Even though there hasn't been any positive feedback, there was no negative
feedback neither, so I've committed this fix now. We need to get 2.0.1 out:

2004-04-10  Sven Neumann  <sven@gimp.org>
 
        * tools/gimp-remote.c (start_new_gimp): reverted the last change
        and did a different fix that involves closing the X display before
        starting gimp (bug #139158).
Comment 27 Stanislav Brabec 2004-04-13 10:53:47 UTC
It seems, that patch in comment #22 does not help. Authorization key probably
cannot be re-used even after explicit XCloseDisplay().

How to repeat the problem: At least XDM and KDM can be switched to use
XDM-AUTHENTICATION-1 key. For XDM see /etc/X11/xdm/xdm-config.

It seems, that fork() is only work-around. If there can be any check for this
bug in configure, fork() code described in comment #12 can be optional.
Comment 28 Sven Neumann 2004-04-13 12:42:22 UTC
The xdm/gdm configuration cannot possibly be checked in configure.
Comment 29 Stanislav Brabec 2004-04-13 12:51:34 UTC
I didn't mentioned XDM checking, but checking for ConnDis.c:GetAuthorization
XLib bug. I have no idea, how to simply check for it. Maybe simplest is list of
X versions with this bug (all version of XFree until now, probably latest Xorg,
too).

For affected versions make a fork(), for other versions (none yet) do not fork.
Comment 30 Sven Neumann 2004-04-13 13:20:06 UTC
We can also hardly check for the X11 version because we cannot know the version
of the X11 library GIMP will be run on when the GIMP configure check is done.
Theoretically we could check the version at run-time but that doesn't sound
feasible.

If this is really an X11 bug I tend to say that it should be fixed in X11 then.
But since a lot of systems seems affected we should consider to workaround it
using fork(). There weren't any good arguments not to use fork(), so if you
think there are any, please speak up.
Comment 31 Stanislav Brabec 2004-04-13 13:28:48 UTC
All XFree system are affected, if you use XDM authentization instead of MIT
magic cookie.

None good arguments against fork(), except startup notification. See comment #12
- it can work (not yet tested).
Comment 32 Sven Neumann 2004-04-13 16:53:13 UTC
2004-04-13  Sven Neumann  <sven@gimp.org>
 
        * tools/gimp-remote.c: reverted last change and go back to the
        solution using fork(). Hopefully fixes bug #139158 this time.