| Ticket UUID: | 3546073 | |||
| Title: | crashing on exit when /tmp is cleaned (unix socket deleted) | |||
| Type: | Bug | Version: | obsolete: 8.5.11 | |
| Submitter: | Created on: | 2012-07-19 21:05:35 | ||
| Subsystem: | 67. Unix Window Operations | Assigned To: | jenglish | |
| Priority: | 3 Low | Severity: | ||
| Status: | Closed | Last Modified: | 2012-09-15 10:44:11 | |
| Resolution: | Fixed | Closed By: | jenglish | |
| Closed on: | 2012-07-31 05:08:02 | |||
| Description: |
The easiest way to reproduce the problem is using wish application supplied by tktoolkit. The setup is the following. 1. We need to start vncserver on linux machine. 2. Delete files under /tmp, more precisely /tmp/.X11-unix/* which stores the unix sockets for VNC servers. 3. Make sure DISPLAY variable is set to this format: ":port.screen" so that machine name is omitted. For example: "setenv DISPLAY :1". This is important as missing display name forces Tk to use unix sockets. 4. Start wish and notice long start up time which will be explained later. 5. Type exit in wish console and tool crashes with the following stack: ============================================= #0 0x00000000004c7026 in TkWmDeadWindow (winPtr=0xa03fb0) at tcltk/tk8.5.11/unix/../unix/tkUnixWm.c:904 #1 0x0000000000419325 in Tk_DestroyWindow (tkwin=0xa03fb0) at tcltk/tk8.5.11/unix/../generic/tkWindow.c:1441 #2 0x00000000004c5290 in TkSendCleanup (dispPtr=0x8d2e50) at tcltk/tk8.5.11/unix/../unix/tkUnixSend.c:1316 #3 0x00000000004b8875 in TkpCloseDisplay (dispPtr=0x8d2e50) at tcltk/tk8.5.11/unix/../unix/tkUnixEvent.c:155 #4 0x0000000000417b9b in TkCloseDisplay (dispPtr=0x8d2e50) at tcltk/tk8.5.11/unix/../generic/tkWindow.c:300 #5 0x000000000041aaa8 in DeleteWindowsExitProc (clientData=0x8cc270) at tcltk/tk8.5.11/unix/../generic/tkWindow.c:2818 #6 0x00000000004e6cb9 in TkFinalizeThread (clientData=0x0) at tcltk/tk8.5.11/unix/../generic/tkEvent.c:2112 #7 0x000000000057dd64 in Tcl_FinalizeThread () at tcltk/tcl8.5.11/unix/../generic/tclEvent.c:1235 #8 0x000000000057dc3a in Tcl_Finalize () at tcltk/tcl8.5.11/unix/../generic/tclEvent.c:1054 #9 0x000000000057db1c in Tcl_Exit (status=0) at tcltk/tcl8.5.11/unix/../generic/tclEvent.c:906 #10 0x0000000000526938 in Tcl_ExitObjCmd (dummy=0x0, interp=0x8a8250, objc=1, objv=0x8aa128) at tcltk/tcl8.5.11/unix/../generic/tclCmdAH.c:726 #11 0x000000000051ad6d in TclEvalObjvInternal (interp=0x8a8250, objc=1, objv=0x8aa128, command=0xffffffffffffffff <Address 0xffffffffffffffff out of bounds>, length=-1, flags=0) at tcltk/tcl8.5.11/unix/../generic/tclBasic.c:3703 #12 0x0000000000581385 in TclExecuteByteCode (interp=0x8a8250, codePtr=0xb5d940) at tcltk/tcl8.5.11/unix/../generic/tclExecute.c:2416 #13 0x000000000057f4a0 in TclCompEvalObj (interp=0x8a8250, objPtr=0xb2adb0, invoker=0x0, word=0) at tcltk/tcl8.5.11/unix/../generic/tclExecute.c:1538 #14 0x000000000051d22b in TclEvalObjEx (interp=0x8a8250, objPtr=0xb2adb0, flags=131072, invoker=0x0, word=0) at tcltk/tcl8.5.11/unix/../generic/tclBasic.c:5272 #15 0x000000000051cdbf in Tcl_EvalObjEx (interp=0x8a8250, objPtr=0x190, flags=131072) at tcltk/tcl8.5.11/unix/../generic/tclBasic.c:5054 #16 0x0000000000596575 in Tcl_RecordAndEvalObj (interp=0x8a8250, cmdPtr=0xb2adb0, flags=131072) at tcltk/tcl8.5.11/unix/../generic/tclHistory.c:159 #17 0x00000000005962e6 in Tcl_RecordAndEval (interp=0x8a8250, cmd=0x8c7978 "exit\n", flags=131072) at tcltk/tcl8.5.11/unix/../generic/tclHistory.c:57 #18 0x0000000000417864 in StdinProc (clientData=0xb34c00, mask=2) at tcltk/tk8.5.11/unix/../generic/tkMain.c:380 #19 0x00000000005a6cb5 in Tcl_NotifyChannel (channel=0xb34c00, mask=2) at tcltk/tcl8.5.11/unix/../generic/tclIO.c:7836 #20 0x000000000060a38e in FileHandlerEventProc (evPtr=0xb543c0, flags=-3) at tcltk/tcl8.5.11/unix/../unix/tclUnixNotfy.c:637 #21 0x00000000005c6218 in Tcl_ServiceEvent (flags=-3) at tcltk/tcl8.5.11/unix/../generic/tclNotify.c:675 #22 0x00000000005c665f in Tcl_DoOneEvent (flags=-3) at tcltk/tcl8.5.11/unix/../generic/tclNotify.c:978 #23 0x00000000004e6cea in Tk_MainLoop () at tcltk/tk8.5.11/unix/../generic/tkEvent.c:2139 #24 0x00000000004176d1 in Tk_MainEx (argc=-1, argv=0x7fbfffed50, appInitProc=0x417043 <Tcl_AppInit>, interp=0x8a8250) at tcltk/tk8.5.11/unix/../generic/tkMain.c:311 #25 0x0000000000417037 in main (argc=1, argv=0x7fbfffed48) at tcltk/tk8.5.11/unix/../unix/tkAppInit.c:66 ============================================= The reason for the crash is some reference counter messed up on application start up. Due to missing socket file deleted from /tmo/.X11-unix directory the tktoolkit tries to open display twice. First time it happens here. Please notice display name ":8.0". ============================================= #0 TkpOpenDisplay (displayNameStr=0x8d9620 ":8.0") at tcltk/tk8.5.11/unix/../unix/tkUnixEvent.c:119 #1 0x0000000000417e4e in GetScreen (interp=0x8a8250, screenName=0x8d9620 ":8.0", screenPtr=0x7fbfffe4e4) at tcltk/tk8.5.11/unix/../generic/tkWindow.c:494 #2 0x0000000000417c77 in CreateTopLevelWindow (interp=0x8a8250, parent=0x0, name=0x7fbfffe7f8 "wish8.5", screenName=0x623f5a "", flags=0) at tcltk/tk8.5.11/unix/../generic/tkWindow.c:380 #3 0x00000000004186fa in TkCreateMainWindow (interp=0x8a8250, screenName=0x623f5a "", baseName=0x7fbfffe7f8 "wish8.5") at tcltk/tk8.5.11/unix/../generic/tkWindow.c:883 #4 0x0000000000424fe6 in CreateFrame (clientData=0x0, interp=0x8a8250, objc=4, objv=0x8c9d90, type=TYPE_TOPLEVEL, appName=0x7fbfffe7f8 "wish8.5") at tcltk/tk8.5.11/unix/../generic/tkFrame.c:556 #5 0x0000000000424bcf in TkCreateFrame (clientData=0x0, interp=0x8a8250, argc=4, argv=0x7fbfffe8c0, toplevel=1, appName=0x7fbfffe7f8 "wish8.5") at tcltk/tk8.5.11/unix/../generic/tkFrame.c:439 #6 0x000000000041b13d in Initialize (interp=0x8a8250) at tcltk/tk8.5.11/unix/../generic/tkWindow.c:3163 #7 0x000000000041ab05 in Tk_Init (interp=0x8a8250) at tcltk/tk8.5.11/unix/../generic/tkWindow.c:2854 #8 0x0000000000417073 in Tcl_AppInit (interp=0x8a8250) at tcltk/tk8.5.11/unix/../unix/tkAppInit.c:96 #9 0x000000000041753d in Tk_MainEx (argc=-1, argv=0x7fbfffed50, appInitProc=0x417043 <Tcl_AppInit>, interp=0x8a8250) at tcltk/tk8.5.11/unix/../generic/tkMain.c:249 #10 0x0000000000417037 in main (argc=1, argv=0x7fbfffed48) at tcltk/tk8.5.11/unix/../unix/tkAppInit.c:66 ============================================= Second attempt to open display happens here. Please notice display name "localhost:8.0" which would force to use tcpip sockets instead of unix sockets to opening display. ============================================= #0 0x00000000004c7026 in TkWmDeadWindow (winPtr=0xa03fb0) at tcltk/tk8.5.11/unix/../unix/tkUnixWm.c:904 #1 0x0000000000419325 in Tk_DestroyWindow (tkwin=0xa03fb0) at tcltk/tk8.5.11/unix/../generic/tkWindow.c:1441 #2 0x00000000004c5290 in TkSendCleanup (dispPtr=0x8d2e50) at tcltk/tk8.5.11/unix/../unix/tkUnixSend.c:1316 #3 0x00000000004b8875 in TkpCloseDisplay (dispPtr=0x8d2e50) at tcltk/tk8.5.11/unix/../unix/tkUnixEvent.c:155 #4 0x0000000000417b9b in TkCloseDisplay (dispPtr=0x8d2e50) at tcltk/tk8.5.11/unix/../generic/tkWindow.c:300 #5 0x000000000041aaa8 in DeleteWindowsExitProc (clientData=0x8cc270) at tcltk/tk8.5.11/unix/../generic/tkWindow.c:2818 #6 0x00000000004e6cb9 in TkFinalizeThread (clientData=0x0) at tcltk/tk8.5.11/unix/../generic/tkEvent.c:2112 #7 0x000000000057dd64 in Tcl_FinalizeThread () at tcltk/tcl8.5.11/unix/../generic/tclEvent.c:1235 #8 0x000000000057dc3a in Tcl_Finalize () at tcltk/tcl8.5.11/unix/../generic/tclEvent.c:1054 #9 0x000000000057db1c in Tcl_Exit (status=0) at tcltk/tcl8.5.11/unix/../generic/tclEvent.c:906 #10 0x0000000000526938 in Tcl_ExitObjCmd (dummy=0x0, interp=0x8a8250, objc=1, objv=0x8aa128) at tcltk/tcl8.5.11/unix/../generic/tclCmdAH.c:726 #11 0x000000000051ad6d in TclEvalObjvInternal (interp=0x8a8250, objc=1, objv=0x8aa128, command=0xffffffffffffffff <Address 0xffffffffffffffff out of bounds>, length=-1, flags=0) at tcltk/tcl8.5.11/unix/../generic/tclBasic.c:3703 #12 0x0000000000581385 in TclExecuteByteCode (interp=0x8a8250, codePtr=0xb5d940) at tcltk/tcl8.5.11/unix/../generic/tclExecute.c:2416 #13 0x000000000057f4a0 in TclCompEvalObj (interp=0x8a8250, objPtr=0xb2adb0, invoker=0x0, word=0) at tcltk/tcl8.5.11/unix/../generic/tclExecute.c:1538 #14 0x000000000051d22b in TclEvalObjEx (interp=0x8a8250, objPtr=0xb2adb0, flags=131072, invoker=0x0, word=0) at tcltk/tcl8.5.11/unix/../generic/tclBasic.c:5272 #15 0x000000000051cdbf in Tcl_EvalObjEx (interp=0x8a8250, objPtr=0x190, flags=131072) at tcltk/tcl8.5.11/unix/../generic/tclBasic.c:5054 #16 0x0000000000596575 in Tcl_RecordAndEvalObj (interp=0x8a8250, cmdPtr=0xb2adb0, flags=131072) at tcltk/tcl8.5.11/unix/../generic/tclHistory.c:159 #17 0x00000000005962e6 in Tcl_RecordAndEval (interp=0x8a8250, cmd=0x8c7978 "exit\n", flags=131072) at tcltk/tcl8.5.11/unix/../generic/tclHistory.c:57 #18 0x0000000000417864 in StdinProc (clientData=0xb34c00, mask=2) at tcltk/tk8.5.11/unix/../generic/tkMain.c:380 #19 0x00000000005a6cb5 in Tcl_NotifyChannel (channel=0xb34c00, mask=2) at tcltk/tcl8.5.11/unix/../generic/tclIO.c:7836 #20 0x000000000060a38e in FileHandlerEventProc (evPtr=0xb543c0, flags=-3) at tcltk/tcl8.5.11/unix/../unix/tclUnixNotfy.c:637 #21 0x00000000005c6218 in Tcl_ServiceEvent (flags=-3) at tcltk/tcl8.5.11/unix/../generic/tclNotify.c:675 #22 0x00000000005c665f in Tcl_DoOneEvent (flags=-3) at tcltk/tcl8.5.11/unix/../generic/tclNotify.c:978 #23 0x00000000004e6cea in Tk_MainLoop () at tcltk/tk8.5.11/unix/../generic/tkEvent.c:2139 #24 0x00000000004176d1 in Tk_MainEx (argc=-1, argv=0x7fbfffed50, appInitProc=0x417043 <Tcl_AppInit>, interp=0x8a8250) at tcltk/tk8.5.11/unix/../generic/tkMain.c:311 #25 0x0000000000417037 in main (argc=1, argv=0x7fbfffed48) at tcltk/tk8.5.11/unix/../unix/tkAppInit.c:66 ============================================= | |||
| User Comments: |
jenglish added on 2012-09-15 10:44:11:
Followup: looks like the fix for this bug introduced new crashes on OSX (since fixed; see #3567812, #3567779, and <URL: http://core.tcl.tk/tk/info/50e0c049b213060b5192947c81ae8cded172aae9 >). jenglish added on 2012-07-31 12:08:02: allow_comments - 1 It seems unlikely that there will be an 8.4.20 release, but backported fix to core-8-4-branch anyway just in case. (ref: http://core.tcl.tk/tk/info/61b638f627 ) jenglish added on 2012-07-24 05:52:07: Proposed fix: Minimal-impact fix would be to replace DisplayString(dispPtr->display) with dispPtr->name in the Tk_CreateWindow() call. Better fix is to call TkAllocWindow() directly, since in this code path that's all that Tk_CreateWindow() ends up doing anyway (except that it also calls TkWmNewWindow(), and this case we don't want that either.) jenglish added on 2012-07-24 05:50:49: Cause of problem:
SendInit(interp,dispPtr) calls:
dispPtr->commTkwin = Tk_CreateWindow(interp, (Tk_Window) NULL,
"_comm", DisplayString(dispPtr->display));
This assumes that GetScreen(DisplayString(dispPtr->display)) will
always return dispPtr. According to the X11 manpages:
| The DisplayString macro returns the string that was passed
| to XOpenDisplay when the current display was opened.
so this sounds like a valid assumption, but it turns out not to hold --
in this case DisplayString(XOpenDisplay(":1")) ends up as "localhost:1.0",
instead of ":1.0". (The manpage lies in any event -- even under
normal conditions DisplayString(dpy) isn't always the string
passed to XOpenDisplay()).
So what happens is: GetScreen() opens a new TkDisplay and creates
the "_comm" window there instead. Then at shutdown time,
TkpCloseDisplay(dispPtr) calls Tk_DestroyWindow(dispPtr->commTkWin),
which crashes because commTkWin->dispPtr has already been cleaned up.
Similar issue occurs in TkClipInit() with the clipboard window.
jenglish added on 2012-07-24 04:29:10: Update: bug does _not_ manifest on CentOS 6.
On affected machines: (vncserver running on :1, /tmp/.X11-unix/X1 removed):
$ env DISPLAY=:1 strace -e connect wish
connect(5, {sa_family=AF_FILE, path="/tmp/.X11-unix/X1"}, 19) = -1 ENOENT (No such file or directory)
connect(5, {sa_family=AF_FILE, path="/tmp/.X11-unix/X1"}, 19) = -1 ENOENT (No such file or directory)
[repeats 6x, ~1/sec]
connect(6, {sa_family=AF_FILE, path="/var/run/nscd/socket"}, 110) = -1 ENOENT (No such file or directory)
connect(6, {sa_family=AF_FILE, path="/var/run/nscd/socket"}, 110) = -1 ENOENT (No such file or directory)
connect(5, {sa_family=AF_INET, sin_port=htons(6001), sin_addr=inet_addr("127.0.0.1")}, 16) = 0
connect(6, {sa_family=AF_INET, sin_port=htons(6001), sin_addr=inet_addr("127.0.0.1")}, 16) = 0
and [exit] dies with a SIGABRT.
So it looks like on this platform it's trying a Unix-domain socket (6 times), then falls back to an IPv4 socket.
On CentOS 6, same setup:
$ env DISPLAY=:1 strace -e connect wish
connect(3, {sa_family=AF_FILE, path="/var/run/nscd/socket"}, 110) = -1 ENOENT (No such file or directory)
connect(3, {sa_family=AF_FILE, path="/var/run/nscd/socket"}, 110) = -1 ENOENT (No such file or directory)
connect(3, {sa_family=AF_FILE, path=@"/tmp/.X11-unix/X1"}, 20) = 0
and [exit] terminates successfully.
added on 2012-07-21 00:52:08: Thank you for the update. If 8.4 code stream is still alive, it would be nice to have the bug fixed there too as that's the version we are currently using. jenglish added on 2012-07-20 10:26:20: > RedHat Enterprise Linux 4.0 U8 OK, able to replicate now. Bug manifests on all the CentOS and Fedora machines I've tried, just not on Debian. Affects Tk at least as far back as 8.4.13, looks like it's present in trunk as well. added on 2012-07-20 07:40:10: In our scenario first call of XOpenDisplay does not fail, but returns after some delay with dispPtr->display_name returned points at "localhost:8.0" although the initial display name was ":8.0". Since display name returned does not match with original, Tk tries to open display second time. It looks as our version of XOpenDisplay is working in some sort of fail-over mode. Here is our platform details. OS: Linux 2.6.9-89.ELsmp x86_64 RedHat Enterprise Linux 4.0 U8 X11: libX11.so.6.2 VNC Server: TightVNC version 1.2.8 jenglish added on 2012-07-20 06:13:33: Unable to replicate with the recipe given above.
At step (4), there is a 5-6 second delay (as expected), then wish exits ("application-specific initialization failed: couldn't connect to display ":1", which is also what I'd expect; it doesn't crash or coredump).
| |||
Home
Timeline
Branches
Tags
Forum
Tickets
Download
Wiki