Tk Source Code

View Ticket
Login
Ticket UUID: 755530
Title: XIMPeek wrong for newer XFree86, panics
Type: Bug Version: None
Submitter: xtifr Created on: 2003-06-16 20:43:59
Subsystem: 84. Unix Build Assigned To: mdejong
Priority: 8 Severity:
Status: Closed Last Modified: 2003-07-17 03:01:26
Resolution: Fixed Closed By: mdejong
    Closed on: 2003-07-16 01:20:59
Description:
As reported by dliigent Debian user Geoffrey Lee at
<http://bugs.debian.org/170504>, the XIMPeek structure
added to unix/tkUnixEvent.c in 8.4.1 does not
correspond to the X internal (hidden) _XIM structure,
at least not with the latest versions of XFree86.  The
XFree86 _XIM structure has one additional member before
the input context pointer.  The result is spurious
panics with the message "input contexts not freed
before XCloseIM".

The code in question can be seen with "cvs diff
-rcore-8-4-0 -rcore-8-4-1 tkUnixEvent.c".  This is the
only change made to tkUnixEvent.c between 8.4.0 and 8.4.1.

The comments in the patch suggest that this was added
as a workaround to certain buggy implementations of
X11.  (Solaris 2.3  1/6/95 is mentioned.)  Presumably,
it was made into a default on the theory that struct
_XIM would be the same across platforms and the test
would therefore be harmless.  Either this theory has
been proven incorrect, or the patch is just broken, and
needs one extra "junk" member in the XIMPeek structure.
 If the former, then perhaps the patch should be made
conditional for just those platforms that are known to
need it; if the latter, perhaps the new junk member
should just be added.

I don't have a Solaris 2.3 system to check, so I'm not
sure what the proper approach would be.
User Comments: xtifr added on 2003-07-17 03:01:26:
Logged In: YES 
user_id=25775

hi, sorry I didn't ever manage to find time to test this.
Life ended up interfering -  I've been rather swamped
lately, and my users had the no-peek version to tide them
over (which is all that 90% of them needed).  Anyway, as I
said before, the new patch certainly looks reasonable, so
I'm perfectly content with the situation as it stands.

thanks

mdejong added on 2003-07-16 08:20:59:
Logged In: YES 
user_id=90858

Adding to the 8.4 branch and closing.

mdejong added on 2003-07-11 01:15:03:
Logged In: YES 
user_id=90858

Any results?

xtifr added on 2003-07-03 06:12:30:
Logged In: YES 
user_id=25775

Yes, the new patch looks much better.  I'll try to get it
tested this week, if life doesn't interfere too much.

mdejong added on 2003-07-02 16:28:37:

File Added - 54706: peek.patch

mdejong added on 2003-07-02 16:28:36:
Logged In: YES 
user_id=90858

The attached patch should solve the problem and make the
comments
in the source file more clear. Please give it a test run on
your system
with XFree86 4.2 to make sure the runtime version check is
working.
I have already checked it into the CVS HEAD, but I can also
check
it into the 8.4 branch if it is no longer panicing with 4.2.

xtifr added on 2003-06-21 09:31:33:
Logged In: YES 
user_id=25775

The submitter is an official representative of the largest
noncommercial Linux distribution in the world, the Debian
Project.  And it doesn't matter what version/flavor of X I
use; what matters is what our users use.  Which is all over
the map.  The Debian tk package dependenciies on xlibs
(which are generated automatically for me by the Debian
XFree86 maintainer) say 4.1.0 or better.  I could override
that, but it's non-trivial to do so, and such hacks are
fragile and often come back to bite you later.  So that's
really no help.

Adding defines is right out, because the decision has to be
made at run time.  Ditto for trying to decide the size of
the structure - the decision has to be made at run time,
because it varies between API-compatible versions of
XFree86.  It's not part of the public API, which is why
trying to examine it is both difficult and dangerous.

I sympathize with your position, but from where I sit,
random, hard-to-diagnose crashes with older, buggy xlibs
sound better than random, hard-to-justify panics with newer,
working xlibs. So, I'm making an executive decision to
remove PEEK_XCLOSEIM from Debian, period.  In other words, I
agree with Joe that this seems to be a bigger maintenance
problem than what it's trying to solve, and I'm in a
position to do something about it, at least for my users. 
What you do with your system is up to you, but I strongly
recommend that you do something, as the current code seems
to be badly broken with newer versions of XFree86. 

cheers

mdejong added on 2003-06-21 04:05:28:
Logged In: YES 
user_id=90858

It is not true that this check has no value in a production
environment. It does cause a crash in a known location,
but this is much better than what we had before which
was a random crash somewhere, which was just about
impossible to debug. Also, these sorts of problems don't
tend to show up in a developers environment because
developers don't tend to upgrade systems that often.

Also, this check is only enabled under Linux, it is not
done on other systems. The real fix is to patch the problem
in X11 so that the crash never happens. I sent a patch in
to the XFree project and they added it, I think it is
included in the XFree86 4.2.1 release. If my patch is
included in the XFree version in use, then it is safe to
remove the PEEK_XCLOSEIM. What version of XFree86
does the submitter use?

The other thing that can be done is to add some #defines
that will take the changes to the internal XIM struct
 into account. Does the structure just need one more
32bit junk member added to it? How can we test at
configure time to know which versions need the old
structure size and which need the newer one? Can the
size of the XIM structure be used in a configure test?

jenglish added on 2003-06-21 02:14:01:
Logged In: YES 
user_id=68433

See also SF bugs #644409 and #630533.

The code in question is apparently a maintenance aid, to
make sure that resources get cleaned up properly.  (Resource
cleanup has been a longstanding thorny issue in Tk; if done
improperly it would cause a crash on _some_ systems.   The
panic() call ensures that it crashes on _all_ systems.)

ISTM that this has become a bigger maintenance problem than
the one it was trying to solve, but that's really Mo
Dejong's call;  assigning this bug to him.

Chris -- for the Debian build, it's safe to disable this
altoghether (either patch tkUnixEvent.c to take out the '#if
PEEK_XCLOSEIM' sections or patch tcl.m4 to not define
PEEK_XCLOSEIM).  The code has no functional purpose in
production builds, it's only useful for maintenance
programmers.

Attachments: