i3 pledge abort with append_layout command

classic Classic list List threaded Threaded
5 messages Options
Reply | Threaded
Open this post in threaded view
|

i3 pledge abort with append_layout command

Ralf Horstmann-2
Hi,

with i3-4.17 and i3-4.17.1 from snapshots on amd64 -current, i3 is terminated by
pledge() when using the append_layout feature. The previous package version
4.16.1p0 works fine. The offending syscall is shmget(), dmesg says:

    i3[72874]: pledge "", syscall 289

The backtrace looks like this (after rebuilding 4.17.1 from ports tree with
debug symbols):

#0  shmget () at -:3
#1  0x0000049c13dc2443 in _cairo_xcb_connection_get () from /usr/local/lib/libcairo.so.13.0
#2  0x0000049c13dc3d96 in _cairo_xcb_screen_get () from /usr/local/lib/libcairo.so.13.0
#3  0x0000049c13dc626b in cairo_xcb_surface_create () from /usr/local/lib/libcairo.so.13.0
#4  0x00000499537fcab4 in draw_util_surface_init (conn=0x49c37a1a000, surface=0x49c3aa3c5a0, drawable=Variable "drawable" is not available.
)
    at /home/obj/i3-4.17.1/i3-4.17.1/../i3-4.17.1/libi3/draw_util.c:51
#5  0x00000499537ef08c in open_placeholder_window (con=0x49bc4ae2c00)
    at /home/obj/i3-4.17.1/i3-4.17.1/../i3-4.17.1/src/restore_layout.c:224
#6  0x00000499537ef128 in open_placeholder_window (con=0x49b9a875600)
    at /home/obj/i3-4.17.1/i3-4.17.1/../i3-4.17.1/src/restore_layout.c:238
#7  0x00000499537eee78 in restore_open_placeholder_windows (parent=0x49bb2739a00)
    at /home/obj/i3-4.17.1/i3-4.17.1/../i3-4.17.1/src/restore_layout.c:255
#8  0x00000499537c0bbd in cmd_append_layout (current_match=Variable "current_match" is not available.
)
    at /home/obj/i3-4.17.1/i3-4.17.1/../i3-4.17.1/src/commands.c:839
#9  0x00000499537c7df0 in next_state (token=Variable "token" is not available.
) at GENERATED_command_call.h:246
#10 0x00000499537c6fdf in parse_command (
    input=0x49bab6a4a00 "workspace 1; append_layout ~/.i3/workspace-sample.json", gen=Variable "gen" is not available.
)
    at /home/obj/i3-4.17.1/i3-4.17.1/../i3-4.17.1/src/commands_parser.c:349
#11 0x00000499537de3ea in handle_run_command (client=0x49bfe6f0780, message=Variable "message" is not available.
)
    at /home/obj/i3-4.17.1/i3-4.17.1/../i3-4.17.1/src/ipc.c:231
#12 0x00000499537dfbeb in ipc_receive_message (loop=Variable "loop" is not available.
)
    at /home/obj/i3-4.17.1/i3-4.17.1/../i3-4.17.1/src/ipc.c:1360
#13 0x0000049bd5c7e10f in ev_invoke_pending () from /usr/local/lib/libev.so.3.1
#14 0x0000049bd5c7f004 in ev_run () from /usr/local/lib/libev.so.3.1
#15 0x00000499537e6ad3 in main (argc=Variable "argc" is not available.
) at ev.h:837

Here is a minimal ~/.i3/config to reproduce:

# i3 config file (v4)
font -misc-fixed-medium-r-normal--13-120-75-75-C-70-iso10646-1
exec --no-startup-id "i3-msg 'workspace 1; append_layout ~/.i3/workspace-sample.json'"

To be used with this ~/.i3/workspace-sample.json:

{
    // stacked split container with 2 children
    "border": "normal",
    "floating": "auto_off",
    "layout": "stacked",
    "percent": 0.5,
    "type": "con",
    "nodes": [
        {
            "border": "normal",
            "current_border_width": 2,
            "floating": "auto_off",
            "geometry": {
               "height": 364,
               "width": 644,
               "x": 0,
               "y": 0
            },
            "name": "tmux",
            "percent": 0.5,
            "swallows": [
               {
               // "class": "^XTerm$",
               // "instance": "^xterm$",
               "title": "^tmux$"
               // "transient_for": "^$"
               }
            ],
            "type": "con"
        }
    ]
}

The problem can also be reproduced in version 4.17 and 4.17.1 by running the
i3-msg append_layout from a terminal after i3 has started. In 4.16.1p0 there is
no abort either.

The pledge() call hasn't changed between those versions, also the working and
non-working versions all use the same cairo libs. Looks like some internal
change within i3 is causing this.

Cheers,
Ralf

Reply | Threaded
Open this post in threaded view
|

Re: i3 pledge abort with append_layout command

Stuart Henderson
Thanks, I've disabled the pledges for now. The shmget calls are in cairo
so the update will be causing a different path to be taken there. If
someone is interested in bringing back the pledges, comparing library
calls between 4.16.1 and 4.17 (possibly with the help of ltrace) might
be a useful starting point.

On 2019/09/04 21:12, Ralf Horstmann wrote:

> Hi,
>
> with i3-4.17 and i3-4.17.1 from snapshots on amd64 -current, i3 is terminated by
> pledge() when using the append_layout feature. The previous package version
> 4.16.1p0 works fine. The offending syscall is shmget(), dmesg says:
>
>     i3[72874]: pledge "", syscall 289
>
> The backtrace looks like this (after rebuilding 4.17.1 from ports tree with
> debug symbols):
>
> #0  shmget () at -:3
> #1  0x0000049c13dc2443 in _cairo_xcb_connection_get () from /usr/local/lib/libcairo.so.13.0
> #2  0x0000049c13dc3d96 in _cairo_xcb_screen_get () from /usr/local/lib/libcairo.so.13.0
> #3  0x0000049c13dc626b in cairo_xcb_surface_create () from /usr/local/lib/libcairo.so.13.0
> #4  0x00000499537fcab4 in draw_util_surface_init (conn=0x49c37a1a000, surface=0x49c3aa3c5a0, drawable=Variable "drawable" is not available.
> )
>     at /home/obj/i3-4.17.1/i3-4.17.1/../i3-4.17.1/libi3/draw_util.c:51
> #5  0x00000499537ef08c in open_placeholder_window (con=0x49bc4ae2c00)
>     at /home/obj/i3-4.17.1/i3-4.17.1/../i3-4.17.1/src/restore_layout.c:224
> #6  0x00000499537ef128 in open_placeholder_window (con=0x49b9a875600)
>     at /home/obj/i3-4.17.1/i3-4.17.1/../i3-4.17.1/src/restore_layout.c:238
> #7  0x00000499537eee78 in restore_open_placeholder_windows (parent=0x49bb2739a00)
>     at /home/obj/i3-4.17.1/i3-4.17.1/../i3-4.17.1/src/restore_layout.c:255
> #8  0x00000499537c0bbd in cmd_append_layout (current_match=Variable "current_match" is not available.
> )
>     at /home/obj/i3-4.17.1/i3-4.17.1/../i3-4.17.1/src/commands.c:839
> #9  0x00000499537c7df0 in next_state (token=Variable "token" is not available.
> ) at GENERATED_command_call.h:246
> #10 0x00000499537c6fdf in parse_command (
>     input=0x49bab6a4a00 "workspace 1; append_layout ~/.i3/workspace-sample.json", gen=Variable "gen" is not available.
> )
>     at /home/obj/i3-4.17.1/i3-4.17.1/../i3-4.17.1/src/commands_parser.c:349
> #11 0x00000499537de3ea in handle_run_command (client=0x49bfe6f0780, message=Variable "message" is not available.
> )
>     at /home/obj/i3-4.17.1/i3-4.17.1/../i3-4.17.1/src/ipc.c:231
> #12 0x00000499537dfbeb in ipc_receive_message (loop=Variable "loop" is not available.
> )
>     at /home/obj/i3-4.17.1/i3-4.17.1/../i3-4.17.1/src/ipc.c:1360
> #13 0x0000049bd5c7e10f in ev_invoke_pending () from /usr/local/lib/libev.so.3.1
> #14 0x0000049bd5c7f004 in ev_run () from /usr/local/lib/libev.so.3.1
> #15 0x00000499537e6ad3 in main (argc=Variable "argc" is not available.
> ) at ev.h:837
>
> Here is a minimal ~/.i3/config to reproduce:
>
> # i3 config file (v4)
> font -misc-fixed-medium-r-normal--13-120-75-75-C-70-iso10646-1
> exec --no-startup-id "i3-msg 'workspace 1; append_layout ~/.i3/workspace-sample.json'"
>
> To be used with this ~/.i3/workspace-sample.json:
>
> {
>     // stacked split container with 2 children
>     "border": "normal",
>     "floating": "auto_off",
>     "layout": "stacked",
>     "percent": 0.5,
>     "type": "con",
>     "nodes": [
>         {
>             "border": "normal",
>             "current_border_width": 2,
>             "floating": "auto_off",
>             "geometry": {
>                "height": 364,
>                "width": 644,
>                "x": 0,
>                "y": 0
>             },
>             "name": "tmux",
>             "percent": 0.5,
>             "swallows": [
>                {
>                // "class": "^XTerm$",
>                // "instance": "^xterm$",
>                "title": "^tmux$"
>                // "transient_for": "^$"
>                }
>             ],
>             "type": "con"
>         }
>     ]
> }
>
> The problem can also be reproduced in version 4.17 and 4.17.1 by running the
> i3-msg append_layout from a terminal after i3 has started. In 4.16.1p0 there is
> no abort either.
>
> The pledge() call hasn't changed between those versions, also the working and
> non-working versions all use the same cairo libs. Looks like some internal
> change within i3 is causing this.
>
> Cheers,
> Ralf
>

Reply | Threaded
Open this post in threaded view
|

Re: i3 pledge abort with append_layout command

Theo de Raadt-2
I am getting tired of explaining that unveil and pledge cannot be
added to programs this easily.

It is this simple:  If you don't understand the program and all
the depedencies completely, and you introduce pledge and unveil,
and the program behaviour changes or it crashes...

Then you are a terrible developer.  You don't deserve the right to
change code.  You've shown you don't care if the program breaks.
Isn't the goal to make software better, without making it worse?

End of story.

Stuart Henderson <[hidden email]> wrote:

> Thanks, I've disabled the pledges for now. The shmget calls are in cairo
> so the update will be causing a different path to be taken there. If
> someone is interested in bringing back the pledges, comparing library
> calls between 4.16.1 and 4.17 (possibly with the help of ltrace) might
> be a useful starting point.
>
> On 2019/09/04 21:12, Ralf Horstmann wrote:
> > Hi,
> >
> > with i3-4.17 and i3-4.17.1 from snapshots on amd64 -current, i3 is terminated by
> > pledge() when using the append_layout feature. The previous package version
> > 4.16.1p0 works fine. The offending syscall is shmget(), dmesg says:
> >
> >     i3[72874]: pledge "", syscall 289
> >
> > The backtrace looks like this (after rebuilding 4.17.1 from ports tree with
> > debug symbols):
> >
> > #0  shmget () at -:3
> > #1  0x0000049c13dc2443 in _cairo_xcb_connection_get () from /usr/local/lib/libcairo.so.13.0
> > #2  0x0000049c13dc3d96 in _cairo_xcb_screen_get () from /usr/local/lib/libcairo.so.13.0
> > #3  0x0000049c13dc626b in cairo_xcb_surface_create () from /usr/local/lib/libcairo.so.13.0
> > #4  0x00000499537fcab4 in draw_util_surface_init (conn=0x49c37a1a000, surface=0x49c3aa3c5a0, drawable=Variable "drawable" is not available.
> > )
> >     at /home/obj/i3-4.17.1/i3-4.17.1/../i3-4.17.1/libi3/draw_util.c:51
> > #5  0x00000499537ef08c in open_placeholder_window (con=0x49bc4ae2c00)
> >     at /home/obj/i3-4.17.1/i3-4.17.1/../i3-4.17.1/src/restore_layout.c:224
> > #6  0x00000499537ef128 in open_placeholder_window (con=0x49b9a875600)
> >     at /home/obj/i3-4.17.1/i3-4.17.1/../i3-4.17.1/src/restore_layout.c:238
> > #7  0x00000499537eee78 in restore_open_placeholder_windows (parent=0x49bb2739a00)
> >     at /home/obj/i3-4.17.1/i3-4.17.1/../i3-4.17.1/src/restore_layout.c:255
> > #8  0x00000499537c0bbd in cmd_append_layout (current_match=Variable "current_match" is not available.
> > )
> >     at /home/obj/i3-4.17.1/i3-4.17.1/../i3-4.17.1/src/commands.c:839
> > #9  0x00000499537c7df0 in next_state (token=Variable "token" is not available.
> > ) at GENERATED_command_call.h:246
> > #10 0x00000499537c6fdf in parse_command (
> >     input=0x49bab6a4a00 "workspace 1; append_layout ~/.i3/workspace-sample.json", gen=Variable "gen" is not available.
> > )
> >     at /home/obj/i3-4.17.1/i3-4.17.1/../i3-4.17.1/src/commands_parser.c:349
> > #11 0x00000499537de3ea in handle_run_command (client=0x49bfe6f0780, message=Variable "message" is not available.
> > )
> >     at /home/obj/i3-4.17.1/i3-4.17.1/../i3-4.17.1/src/ipc.c:231
> > #12 0x00000499537dfbeb in ipc_receive_message (loop=Variable "loop" is not available.
> > )
> >     at /home/obj/i3-4.17.1/i3-4.17.1/../i3-4.17.1/src/ipc.c:1360
> > #13 0x0000049bd5c7e10f in ev_invoke_pending () from /usr/local/lib/libev.so.3.1
> > #14 0x0000049bd5c7f004 in ev_run () from /usr/local/lib/libev.so.3.1
> > #15 0x00000499537e6ad3 in main (argc=Variable "argc" is not available.
> > ) at ev.h:837
> >
> > Here is a minimal ~/.i3/config to reproduce:
> >
> > # i3 config file (v4)
> > font -misc-fixed-medium-r-normal--13-120-75-75-C-70-iso10646-1
> > exec --no-startup-id "i3-msg 'workspace 1; append_layout ~/.i3/workspace-sample.json'"
> >
> > To be used with this ~/.i3/workspace-sample.json:
> >
> > {
> >     // stacked split container with 2 children
> >     "border": "normal",
> >     "floating": "auto_off",
> >     "layout": "stacked",
> >     "percent": 0.5,
> >     "type": "con",
> >     "nodes": [
> >         {
> >             "border": "normal",
> >             "current_border_width": 2,
> >             "floating": "auto_off",
> >             "geometry": {
> >                "height": 364,
> >                "width": 644,
> >                "x": 0,
> >                "y": 0
> >             },
> >             "name": "tmux",
> >             "percent": 0.5,
> >             "swallows": [
> >                {
> >                // "class": "^XTerm$",
> >                // "instance": "^xterm$",
> >                "title": "^tmux$"
> >                // "transient_for": "^$"
> >                }
> >             ],
> >             "type": "con"
> >         }
> >     ]
> > }
> >
> > The problem can also be reproduced in version 4.17 and 4.17.1 by running the
> > i3-msg append_layout from a terminal after i3 has started. In 4.16.1p0 there is
> > no abort either.
> >
> > The pledge() call hasn't changed between those versions, also the working and
> > non-working versions all use the same cairo libs. Looks like some internal
> > change within i3 is causing this.
> >
> > Cheers,
> > Ralf
> >
>

Reply | Threaded
Open this post in threaded view
|

Re: i3 pledge abort with append_layout command

Rafael Sadowski
In reply to this post by Ralf Horstmann-2
On Wed Sep 04, 2019 at 09:12:59PM +0200, Ralf Horstmann wrote:

> Hi,
>
> with i3-4.17 and i3-4.17.1 from snapshots on amd64 -current, i3 is terminated by
> pledge() when using the append_layout feature. The previous package version
> 4.16.1p0 works fine. The offending syscall is shmget(), dmesg says:
>
>     i3[72874]: pledge "", syscall 289
>
> The backtrace looks like this (after rebuilding 4.17.1 from ports tree with
> debug symbols):
>
> #0  shmget () at -:3
> #1  0x0000049c13dc2443 in _cairo_xcb_connection_get () from /usr/local/lib/libcairo.so.13.0
> #2  0x0000049c13dc3d96 in _cairo_xcb_screen_get () from /usr/local/lib/libcairo.so.13.0
> #3  0x0000049c13dc626b in cairo_xcb_surface_create () from /usr/local/lib/libcairo.so.13.0
> #4  0x00000499537fcab4 in draw_util_surface_init (conn=0x49c37a1a000, surface=0x49c3aa3c5a0, drawable=Variable "drawable" is not available.
> )
>     at /home/obj/i3-4.17.1/i3-4.17.1/../i3-4.17.1/libi3/draw_util.c:51
> #5  0x00000499537ef08c in open_placeholder_window (con=0x49bc4ae2c00)
>     at /home/obj/i3-4.17.1/i3-4.17.1/../i3-4.17.1/src/restore_layout.c:224
> #6  0x00000499537ef128 in open_placeholder_window (con=0x49b9a875600)
>     at /home/obj/i3-4.17.1/i3-4.17.1/../i3-4.17.1/src/restore_layout.c:238
> #7  0x00000499537eee78 in restore_open_placeholder_windows (parent=0x49bb2739a00)
>     at /home/obj/i3-4.17.1/i3-4.17.1/../i3-4.17.1/src/restore_layout.c:255
> #8  0x00000499537c0bbd in cmd_append_layout (current_match=Variable "current_match" is not available.
> )
>     at /home/obj/i3-4.17.1/i3-4.17.1/../i3-4.17.1/src/commands.c:839
> #9  0x00000499537c7df0 in next_state (token=Variable "token" is not available.
> ) at GENERATED_command_call.h:246
> #10 0x00000499537c6fdf in parse_command (
>     input=0x49bab6a4a00 "workspace 1; append_layout ~/.i3/workspace-sample.json", gen=Variable "gen" is not available.
> )
>     at /home/obj/i3-4.17.1/i3-4.17.1/../i3-4.17.1/src/commands_parser.c:349
> #11 0x00000499537de3ea in handle_run_command (client=0x49bfe6f0780, message=Variable "message" is not available.
> )
>     at /home/obj/i3-4.17.1/i3-4.17.1/../i3-4.17.1/src/ipc.c:231
> #12 0x00000499537dfbeb in ipc_receive_message (loop=Variable "loop" is not available.
> )
>     at /home/obj/i3-4.17.1/i3-4.17.1/../i3-4.17.1/src/ipc.c:1360
> #13 0x0000049bd5c7e10f in ev_invoke_pending () from /usr/local/lib/libev.so.3.1
> #14 0x0000049bd5c7f004 in ev_run () from /usr/local/lib/libev.so.3.1
> #15 0x00000499537e6ad3 in main (argc=Variable "argc" is not available.
> ) at ev.h:837
>
> Here is a minimal ~/.i3/config to reproduce:
>
> # i3 config file (v4)
> font -misc-fixed-medium-r-normal--13-120-75-75-C-70-iso10646-1
> exec --no-startup-id "i3-msg 'workspace 1; append_layout ~/.i3/workspace-sample.json'"
>
> To be used with this ~/.i3/workspace-sample.json:
>
> {
>     // stacked split container with 2 children
>     "border": "normal",
>     "floating": "auto_off",
>     "layout": "stacked",
>     "percent": 0.5,
>     "type": "con",
>     "nodes": [
>         {
>             "border": "normal",
>             "current_border_width": 2,
>             "floating": "auto_off",
>             "geometry": {
>                "height": 364,
>                "width": 644,
>                "x": 0,
>                "y": 0
>             },
>             "name": "tmux",
>             "percent": 0.5,
>             "swallows": [
>                {
>                // "class": "^XTerm$",
>                // "instance": "^xterm$",
>                "title": "^tmux$"
>                // "transient_for": "^$"
>                }
>             ],
>             "type": "con"
>         }
>     ]
> }
>
> The problem can also be reproduced in version 4.17 and 4.17.1 by running the
> i3-msg append_layout from a terminal after i3 has started. In 4.16.1p0 there is
> no abort either.

I can't reproduce the pledge issue with i3-gaps-4.17, could you also
test with i3-gaps-4.17 in -current, please.

>
> The pledge() call hasn't changed between those versions, also the working and
> non-working versions all use the same cairo libs. Looks like some internal
> change within i3 is causing this.
>
> Cheers,
> Ralf
>

Reply | Threaded
Open this post in threaded view
|

Re: i3 pledge abort with append_layout command

Ralf Horstmann-2
* Rafael Sadowski <[hidden email]> [2019-09-05 21:15]:
> > The problem can also be reproduced in version 4.17 and 4.17.1 by running the
> > i3-msg append_layout from a terminal after i3 has started. In 4.16.1p0 there is
> > no abort either.
>
> I can't reproduce the pledge issue with i3-gaps-4.17, could you also
> test with i3-gaps-4.17 in -current, please.

Yes, I can reproduce with i3-gaps-4.17 in -current as well.

Maybe your X server doesn't have the SHM extension? Cairo checks the presence
of the SHM extension and will only do shmget if present.

With this I can't reproduce either:
    Section "Extensions"
        Option "MIT-SHM" "Disable"
    EndSection

With some bisecting I found this change to cause the problem:
    https://github.com/i3/i3/commit/01c1b5dec2ae5a3ce54c9e0f41daf540afbf052f

The change causes a second xcb connection to be used to create the placeholder
windows. There is a call to restore_connect() before pledge() in main(), which
might be intended to initialize the second connection. Apparently that is not
working.

Cheers,
Ralf