Skip to content

Instantly share code, notes, and snippets.

@Blub
Created February 9, 2016 14:29
Show Gist options
  • Save Blub/72a7f432fcf8f6513919 to your computer and use it in GitHub Desktop.
Save Blub/72a7f432fcf8f6513919 to your computer and use it in GitHub Desktop.
Curious lxc race condition
1) Log into container and do:
$ while : ; do uptime; done
2) On host do:
$ while : ; do lxc-freeze -n $CT ; lxc-unfreeze -n $CT; done
(or to see stuff happening:)
$ i = 0; while : ; do let i++; echo freeze $i && lxc-freeze -n 104; echo unfreeze && lxc-unfreeze -n 104; done
--
At some point lxc-freeze hangs because uptime's in an uninterruptible
request_wait_answer state waiting for lxcfs to reply, which curiously
hangs in a lock while creating an error message for fork()... See the
gdb output below.
# ps faxl |grep lxcfs
4 0 3774 1 20 0 527956 2132 futex_wait_queue_me Ssl ? 0:10 /usr/bin/lxcfs -f -s -o allow_other /var/lib/lxcfs/
5 0 22927 3774 20 0 380220 788 wait S ? 0:00 \_ /usr/bin/lxcfs -f -s -o allow_other /var/lib/lxcfs/
1 0 22928 22927 20 0 380352 788 futex_wait_queue_me S ? 0:00 \_ /usr/bin/lxcfs -f -s -o allow_other /var/lib/lxcfs/
# (ps faxl portion for the container, no lxc-attach was used so this
includes all of it)
5 0 12569 1 20 0 38768 3448 ep_poll Ss ? 0:02 [lxc monitor] /var/lib/lxc 104
4 0 12651 12569 20 0 34080 4492 refrigerator Ds ? 0:00 \_ /sbin/init
4 0 12815 12651 20 0 30488 5436 refrigerator Ds ? 0:00 \_ /usr/lib/systemd/systemd-journald
4 81 12981 12651 20 0 34748 3444 refrigerator Ds ? 0:00 \_ /usr/bin/dbus-daemon --system --address=systemd: --nofork --nopidfile --systemd-activation
4 0 13016 12651 20 0 15292 2424 refrigerator Ds ? 0:00 \_ /usr/lib/systemd/systemd-logind
4 193 13033 12651 20 0 19792 2688 refrigerator Ds ? 0:00 \_ /usr/lib/systemd/systemd-networkd
4 0 13052 12651 20 0 6348 1664 refrigerator Ds+ pts/7 0:00 \_ /sbin/agetty --noclear --keep-baud console 115200 38400 9600 vt220
4 0 13055 12651 20 0 6348 1544 refrigerator Ds+ pts/1 0:00 \_ /sbin/agetty --noclear --keep-baud pts/1 115200 38400 9600 vt220
4 0 13058 12651 20 0 89728 4128 refrigerator Ds ? 0:00 \_ login -- root
4 0 30296 13058 20 0 14408 3356 refrigerator Ds pts/0 0:01 | \_ -bash
0 0 22921 30296 20 0 31980 2380 request_wait_answer D+ pts/0 0:00 | \_ uptime
4 0 30127 12651 20 0 33752 4128 refrigerator Ds ? 0:00 \_ /usr/lib/systemd/systemd --user
5 0 30159 30127 20 0 96432 1316 sigtimedwait S ? 0:00 \_ (sd-pam)
# gdb
GNU gdb (Debian 7.7.1+dfsg-5) 7.7.1
Copyright (C) 2014 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law. Type "show copying"
and "show warranty" for details.
This GDB was configured as "x86_64-linux-gnu".
Type "show configuration" for configuration details.
For bug reporting instructions, please see:
<http://www.gnu.org/software/gdb/bugs/>.
Find the GDB manual and other documentation resources online at:
<http://www.gnu.org/software/gdb/documentation/>.
For help, type "help".
Type "apropos word" to search for commands related to "word".
(gdb) attach 22928
Attaching to process 22928
Reading symbols from /usr/bin/lxcfs...Reading symbols from /usr/lib/debug/.build-id/bb/195a84f55a59c1bd7df50149bebd5836e2c048.debug...done.
done.
Reading symbols from /lib/x86_64-linux-gnu/libfuse.so.2...(no debugging symbols found)...done.
Loaded symbols for /lib/x86_64-linux-gnu/libfuse.so.2
Reading symbols from /lib/x86_64-linux-gnu/libpthread.so.0...Reading symbols from /usr/lib/debug//lib/x86_64-linux-gnu/libpthread-2.19.so...done.
done.
[Thread debugging using libthread_db enabled]
Using host libthread_db library "/lib/x86_64-linux-gnu/libthread_db.so.1".
Loaded symbols for /lib/x86_64-linux-gnu/libpthread.so.0
Reading symbols from /lib/x86_64-linux-gnu/libc.so.6...Reading symbols from /usr/lib/debug//lib/x86_64-linux-gnu/libc-2.19.so...done.
done.
Loaded symbols for /lib/x86_64-linux-gnu/libc.so.6
Reading symbols from /lib/x86_64-linux-gnu/libdl.so.2...Reading symbols from /usr/lib/debug//lib/x86_64-linux-gnu/libdl-2.19.so...done.
done.
Loaded symbols for /lib/x86_64-linux-gnu/libdl.so.2
Reading symbols from /lib64/ld-linux-x86-64.so.2...Reading symbols from /usr/lib/debug//lib/x86_64-linux-gnu/ld-2.19.so...done.
done.
Loaded symbols for /lib64/ld-linux-x86-64.so.2
__lll_lock_wait_private () at ../nptl/sysdeps/unix/sysv/linux/x86_64/lowlevellock.S:95
95 ../nptl/sysdeps/unix/sysv/linux/x86_64/lowlevellock.S: No such file or directory.
(gdb) bt
#0 __lll_lock_wait_private () at ../nptl/sysdeps/unix/sysv/linux/x86_64/lowlevellock.S:95
#1 0x00007f9552b816db in _L_lock_11305 () from /lib/x86_64-linux-gnu/libc.so.6
#2 0x00007f9552b7f838 in __GI___libc_realloc (oldmem=0x7f9552ea8620 <main_arena>, bytes=bytes@entry=567) at malloc.c:3025
#3 0x00007f9552b7524b in _IO_vasprintf (result_ptr=0x7f95520fc748, format=<optimized out>, args=args@entry=0x7f95520fc628) at vasprintf.c:84
#4 0x00007f9552b54027 in ___asprintf (string_ptr=string_ptr@entry=0x7f95520fc748, format=format@entry=0x7f9552c6a688 "%s%s%s:%u: %s%sAssertion `%s' failed.\n%n") at asprintf.c:35
#5 0x00007f9552b311c2 in __assert_fail_base (fmt=0x7f9552c6a688 "%s%s%s:%u: %s%sAssertion `%s' failed.\n%n",
assertion=assertion@entry=0x7f9552c6d9a0 "({ __typeof (self->tid) __value; if (sizeof (__value) == 1) asm volatile (\"movb %%fs:%P2,%b0\" : \"=q\" (__value) : \"0\" (0), \"i\" (__builtin_offsetof (struct pthread, tid))); else if (sizeof (__value) == "..., file=file@entry=0x7f9552c6d968 "../nptl/sysdeps/unix/sysv/linux/x86_64/../fork.c", line=line@entry=141,
function=function@entry=0x7f9552c681b2 <__PRETTY_FUNCTION__.11206> "__libc_fork") at assert.c:57
#6 0x00007f9552b31312 in __GI___assert_fail (
assertion=0x7f9552c6d9a0 "({ __typeof (self->tid) __value; if (sizeof (__value) == 1) asm volatile (\"movb %%fs:%P2,%b0\" : \"=q\" (__value) : \"0\" (0), \"i\" (__builtin_offsetof (struct pthread, tid))); else if (sizeof (__value) == "..., file=0x7f9552c6d968 "../nptl/sysdeps/unix/sysv/linux/x86_64/../fork.c", line=141, function=0x7f9552c681b2 <__PRETTY_FUNCTION__.112
06> "__libc_fork") at assert.c:101
#7 0x00007f9552bbd385 in __libc_fork () at ../nptl/sysdeps/unix/sysv/linux/x86_64/../fork.c:141
#8 0x00007f9552ebf425 in __fork () at ../nptl/sysdeps/unix/sysv/linux/pt-fork.c:25
#9 0x0000000000404dd8 in write_task_init_pid_exit (sock=4, target=<optimized out>) at lxcfs.c:2530
#10 0x0000000000406fac in get_task_reaper_pid (task=<optimized out>) at lxcfs.c:2565
#11 get_reaper_busy (task=<optimized out>) at lxcfs.c:2581
#12 proc_uptime_read (fi=<optimized out>, offset=<optimized out>, size=<optimized out>, buf=<optimized out>) at lxcfs.c:2613
#13 proc_read (path=<optimized out>, fi=<optimized out>, offset=<optimized out>, size=<optimized out>, buf=<optimized out>) at lxcfs.c:2891
#14 lxcfs_read (path=0xfffffffffffffe00 <error: Cannot access memory at address 0xfffffffffffffe00>, buf=0x80 <error: Cannot access memory at address 0x80>, size=8191, offset=0, fi=0x7f953c002eb0) at lxcfs.c:2980
#15 0x00007f95530d8574 in fuse_fs_read_buf () from /lib/x86_64-linux-gnu/libfuse.so.2
#16 0x00007f95530d8732 in ?? () from /lib/x86_64-linux-gnu/libfuse.so.2
#17 0x00007f95530e108e in ?? () from /lib/x86_64-linux-gnu/libfuse.so.2
#18 0x00007f95530e1895 in ?? () from /lib/x86_64-linux-gnu/libfuse.so.2
#19 0x00007f95530de394 in ?? () from /lib/x86_64-linux-gnu/libfuse.so.2
#20 0x00007f9552eb60a4 in start_thread (arg=0x7f95520fd700) at pthread_create.c:309
#21 0x00007f9552beb9cd in clone () at ../sysdeps/unix/sysv/linux/x86_64/clone.S:111
(gdb) c
Continuing.
^C^C^C^C^C^C^C
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment