[Xcb] Question about a xcb_util.c commit

Uli Schlachter psychon at znc.in
Fri Jun 10 16:51:04 UTC 2016


Am 10.06.2016 um 18:34 schrieb David Coppa:
[...]
>> Also: When exactly does i3 pledge()? Does this break e.g.
>> "DISPLAY=1.2.3.4:0
>> i3"? I thought people were "angry" about wayland because it isn't as
>> (pseudo)
>> network transparent as X11
> 
> Yes, running a pledged i3 on a remote X server is not possible, because "inet" has not been declared in the allowed pledges. I think it's an acceptable compromise, and Xorg by default runs with 'nolisten tcp' btw, iirc...
> 
> Mine it's not really a problem, my question was mainly driven by curiosity.
> 
> We had a report by a user some time ago about i3 dumping core, after an X server crash, with a pledge related message:
> 
> i3(49392): syscall 97 "inet"
> 
> The X crash was caused by a bug in the radeon driver, while i3 was killed by the pledge subsystem because of restore_xcb_check_cb() (src/restore_layout.c). If it sees that the
> connection to X has been lost, it calls restore_connect() which calls
> libxcb's xcb_connect().
> In libxcb that calls xcb_connect_to_display_with_auth_info() which calls
> _xcb_open(), which calls _xcb_open_unix() and ususally that would be it,
> but if opening the unix socket fails (beause X has fallen over) it tries
> again to connect by calling _xcb_open_tcp() which sets up an AF_INET addrinfo and passes that to _xcb_socket().

Ah. I neither knew that i3 can survive the X11 connection breaking nor that
pledge() aborts the program instead of making operations fail.

A "weird work-around" that comes to my mind would be to replace conn =
xcb_connect(NULL, &conn_screen); with something like the following (but without
the obvious overflow issues):

char buffer[42];
const char *display = getenv("DISPLAY");
/* Force protocol to be "unix" if no protocol is specified to disable TCP
attempts which pledge() would catch */
if (display != NULL && strchr(display, '/')) {
  sprintf(buffer, "unix/%s", display);
  display = buffer;
}
conn = xcb_connect(display, &conn_screen);

Cheers,
Uli
-- 
- Buck, when, exactly, did you lose your mind?
- Three months ago. I woke up one morning married to a pineapple.
  An ugly pineapple... But I loved her.


More information about the Xcb mailing list