Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Segmentation fault on start #861

Closed
jkobezda opened this issue Aug 18, 2016 · 6 comments
Closed

Segmentation fault on start #861

jkobezda opened this issue Aug 18, 2016 · 6 comments

Comments

@jkobezda
Copy link

I'm getting segmentation faults when starting sway on a new Gentoo Hardened install using musl libc.

Sway output: https://0x0.st/MPr.txt

Dmesg: https://0x0.st/MPs.txt

@jkobezda
Copy link
Author

(gdb) run -dV
Starting program: /usr/bin/sway -dV
08/19/16 09:52:01 - [wlc] Failed to create file for keymap

Program received signal SIGSEGV, Segmentation fault.
free (p=0x7f21953091c0) at src/malloc/malloc.c:464
464 src/malloc/malloc.c: No such file or directory.
(gdb) bt full
#0  free (p=0x7f21953091c0) at src/malloc/malloc.c:464
        self = 0x7f21953091b0
        next = 0x7f21953092b0
        final_size = 256
        new_size = 256
        size = <optimized out>
        reclaim = 0
#1  0x00007f2199162718 in xkb_keymap_unref () from /usr/lib/libxkbcommon.so.0
No symbol table info available.
#2  0x00007f21993974cc in wlc_keymap_release (keymap=keymap@entry=0x7f21995bc8e0 <wlc+544>)
    at /var/tmp/portage/dev-libs/wlc-9999/work/wlc-9999/src/compositor/seat/keymap.c:61
No locals.
#3  0x00007f2199399866 in wlc_seat_release (seat=0x7f21995bc6d8 <wlc+24>) at /var/tmp/portage/dev-libs/wlc-9999/work/wlc-9999/src/compositor/seat/seat.c:284
No locals.
#4  0x00007f2199399a22 in wlc_seat (seat=seat@entry=0x7f21995bc6d8 <wlc+24>)
    at /var/tmp/portage/dev-libs/wlc-9999/work/wlc-9999/src/compositor/seat/seat.c:331
        rules = {rules = 0x0, model = 0x0, layout = 0x0, variant = 0x0, options = 0x0}
#5  0x00007f21993921a5 in wlc_compositor (compositor=compositor@entry=0x7f21995bc6c0 <wlc>)
    at /var/tmp/portage/dev-libs/wlc-9999/work/wlc-9999/src/compositor/compositor.c:766
No locals.
#6  0x00007f21993aaa8c in wlc_init () at /var/tmp/portage/dev-libs/wlc-9999/work/wlc-9999/src/wlc.c:391
        x11display = 0x7ffeb39c4fb0 ":0"
        privileged = <optimized out>
        vt = <optimized out>
        socket_name = <optimized out>
        libinput = <optimized out>
#7  0x00005629867ad6ee in main (argc=2, argv=0x7ffeb39c4618) at /var/tmp/portage/dev-libs/sway-9999/work/sway-9999/sway/main.c:191
        verbose = 1
        debug = 1
        validate = 0
        long_options = {{name = 0x5629867d3f6f "help", has_arg = 0, flag = 0x0, val = 104}, {name = 0x5629867d26d8 "config", has_arg = 1, flag = 0x0, 
            val = 99}, {name = 0x5629867d3f74 "validate", has_arg = 0, flag = 0x0, val = 67}, {name = 0x5629867d3f7d "debug", has_arg = 0, flag = 0x0, 
            val = 100}, {name = 0x5629867d3f83 "version", has_arg = 0, flag = 0x0, val = 118}, {name = 0x5629867d35ca "verbose", has_arg = 0, flag = 0x0, 
            val = 86}, {name = 0x5629867d48af "get-socketpath", has_arg = 0, flag = 0x0, val = 112}, {name = 0x0, has_arg = 0, flag = 0x0, val = 0}}
        config_path = 0x0
        usage = 0x5629867d4098 "Usage: sway [options] [command]\n\n  -h, --help", ' ' <repeats 13 times>, "Show help message and quit.\n  -c, --config <config>  Specify a config file.\n  -C, --validate         Check the validity of the config file, th"...
        c = <optimized out>

@progandy
Copy link
Contributor

That may be the result of a double free bug in wlc. It is called once inside of wlc_keymap in case of an error and once again during wlc_seat_release which is called after wlc_keymap fails

@Cloudef: Should wlc_keymap_release set the structure members to NULL? The alternative may be to do that each time after the wlc_keymap constructor fails.

@jkobezda
Copy link
Author

jkobezda commented Aug 19, 2016

So, the "Failed to create file for keymap" is because I had XDG_RUNTIME_DIR on a ZFS filesystem, which doesn't support fallocate(). See strace:

open("/tmp/john//wlc-shared-PeIHcJ", O_RDWR|O_CREAT|O_EXCL|O_CLOEXEC, 0600) = 10
fcntl(10, F_SETFD, FD_CLOEXEC)          = 0
unlink("/tmp/john//wlc-shared-PeIHcJ")  = 0
fallocate(10, 0, 0, 45094)              = -1 EOPNOTSUPP (Not supported)
close(10)                               = 0
open("/etc/localtime", O_RDONLY|O_NONBLOCK|O_CLOEXEC) = 10
fstat(10, {st_mode=S_IFREG|0644, st_size=2272, ...}) = 0
mmap(NULL, 2272, PROT_READ, MAP_SHARED, 10, 0) = 0x7f84f8cc2000
close(10)                               = 0
writev(2, [{"", 0}, {"08/19/16 15:12:40 - ", 20}], 208/19/16 15:12:40 - ) = 20
ioctl(2, TIOCGWINSZ, 0x7ffcad593100)    = -1 ENOTTY (Not a tty)
writev(2, [{"[wlc] Failed to create file for "..., 38}, {NULL, 0}], 2[wlc] Failed to create file for keymap) = 38
ioctl(2, TIOCGWINSZ, 0x7ffcad593100)    = -1 ENOTTY (Not a tty)
writev(2, [{"", 0}, {"\n", 1}], 2
)      = 1
--- SIGSEGV {si_signo=SIGSEGV, si_code=SI_KERNEL, si_addr=0} ---
+++ killed by SIGSEGV +++
08/19/16 15:12:40 - [wlc] Parent exit (5926)

Edit: openzfs/zfs#326

@Cloudef
Copy link

Cloudef commented Aug 19, 2016

@progandy Cloudef/wlc@fe0a704 Cloudef/wlc@fa780ce Yeah it should.

@Cloudef
Copy link

Cloudef commented Aug 19, 2016

@jkobezda You could try compiling with -UHAVE_POSIX_FALLOCATE compiler flag to fall back to ftruncate.

@jkobezda
Copy link
Author

I worked around it by putting XDG_RUNTIME_DIR on tmpfs.
Also it doesn't segfault anymore. Closing.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

3 participants