8

I have a fairly complicated GUI written through python's tkinter running on linux, and one of the components (which has a Text widget which updates frequently) causes the GUI to crash infrequently (once a day).

The guis are being displayed to X running on both Mac OSX through X11 and Gnome 2.28.2 with the same behavior. My python version is 3.3 and tk/tcl version is 8.5. The error I get is:

X Error of failed request:  BadIDChoice (invalid resource ID chosen for this connection)
  Major opcode of failed request:  148 (RENDER)
  Minor opcode of failed request:  4 (RenderCreatePicture)
  Resource id in failed request:  0x116517f
  Serial number of failed request:  15106831
  Current serial number in output stream:  15106872

a strace looks like:

11:03:29.632041 recvfrom(13, 0x3bae1d4, 4096, 0, 0, 0) = -1 EAGAIN (Resource temporarily unavailable)
11:03:29.632059 recvfrom(13, 0x3bae1d4, 4096, 0, 0, 0) = -1 EAGAIN (Resource temporarily unavailable)
11:03:29.632147 poll([{fd=13, events=POLLIN|POLLOUT}], 1, -1) = 1 ([{fd=13, revents=POLLOUT}])
11:03:29.632164 writev(13, [{"\224\4\5\0D\304\361\0\17\274\361\0i\4\0\0\0\0\0\0\224\27\n\0\3\f\340\0\301\v\340\0"..., 5032}, {NULL, 0}, {"", 0}], 3) = 5032
11:03:29.632193 poll([{fd=13, events=POLLIN}], 1, -1) = 1 ([{fd=13, revents=POLLIN}])
11:03:29.637040 recvfrom(13, "\0\16\302\276x\304\361\0\4\0\224\0\1\0\0\0`\16\330\3\1\0\0\0\243\304\342\210\377\177\0\0"..., 4096, 0, NULL, NULL) = 136
11:03:29.637135 open("/usr/share/X11/XErrorDB", O_RDONLY) = 35
11:03:29.637217 fstat(35, {st_mode=S_IFREG|0644, st_size=41532, ...}) = 0
11:03:29.637360 read(35, "!\n! Copyright 1993, 1995, 1998  "..., 41532) = 41532
11:03:29.637387 close(35)               = 0
11:03:29.637820 write(2, "X Error of failed request:  BadI"..., 91) = 91
...

My GUI is single-threaded (and uses the after() call to monitor sockets for I/O).

Does anyone know what might be wrong? Is there any better debugging that I could be doing to figure out what the X Error part means?

gnr
  • 2,324
  • 1
  • 22
  • 24
  • how much data is going into the text widget? does it grow without bounds, or do you delete old data and replace it with new? Are you using lots of tags? – Bryan Oakley Jan 12 '16 at 16:32
  • @BryanOakley the data/visual output is constantly changing, but it is only limited to a screen's worth. I constantly call `textwin.delete(1.0, END); textwin.insert(END, text)`. I do make heavy use of tags for sure. Is there perhaps a better way / another way I should try to see if I get the same behavior? – gnr Jan 12 '16 at 17:44
  • I was just confirming whether you keep deleting and inserting, versus just infinite inserts. It sounds like you're probably doing it right. – Bryan Oakley Jan 12 '16 at 17:57
  • *(Resource temporarily unavailable)* says the problem is probably the connection, not the program. Test that the connection is active (with ping or whatever) before updating text on a remote machine (it might be filling up a "slow" connection, and/or you might have to flush the buffers after each send to the monitors.). You can also increase the wait time in after() to give it time to clear. –  Jan 12 '16 at 20:52
  • @CurlyJoe thank you, but I don't think this is it either - the strace has this message VERY frequently when everything is working fine. I think it's just how the poll loop reports that there are no sockets which can be read (and it goes back to waiting on a poll() call for a few ms) – gnr Jan 12 '16 at 22:54
  • One thing to try is installing [MacPorts Tcl/Tk](https://www.macports.org/install.php) so that you have a more recent version of Tcl/Tk and see if the same bug occurs. MacPorts Tk can be installed as an X11 version (port install tk +x11). – Brad Lanam Jan 23 '16 at 15:11

1 Answers1

2

Infrequent crashes (once a day) with the following logs...

X Error of failed request:  BadIDChoice (invalid resource ID chosen for this connection)
  Major opcode of failed request:  148 (RENDER)
  Minor opcode of failed request:  4 (RenderCreatePicture)

...appear to be a telltale signature of a known issue within xcb as mentioned in the following thread:

Bug 458092 - Crashes with BadIdChoice X errors

The patch for it is available here.
Based on the git history, this xcb bug should be fixed in libX11-1.1.99.2 and above (~8years ago).


For further reference here is the email-thread with the complete discussion.

TheCodeArtist
  • 21,479
  • 4
  • 69
  • 130
  • thanks for your very helpful answer - however, I am using libxcb version 1.9.1 which I believe has this fix. – gnr Jan 26 '16 at 13:15