Comment 13 for bug 1322751

John (john-levin) wrote :

The PAM user authenticator in the unity lockscreen busy waits because of a bug in std::future in libstdc++6.

The libstdc++ bug is decribed here, including a patch for fixing it:
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=68921
(GCC Bugzilla – Bug 68921 [5/6 Regression] std::future::wait() makes invalid futex calls and spins)

strace on compiz while the lockscreen is active shows the following system call being repeated:
futex(0xb32f7a9c, FUTEX_WAIT, -2147483648, {2948397076, 2}) = -1 EINVAL (Invalid argument)

Here is a backtrace of the affected thread in compiz when it is in that syscall:
#0 0xb7795be8 in __kernel_vsyscall ()
#1 0xb74485a7 in syscall () at ../sysdeps/unix/sysv/linux/i386/syscall.S:29
#2 0xb75d8336 in std::__atomic_futex_unsigned_base::_M_futex_wait_until (this=0xb32f7a9c, __addr=0xb32f7a9c, __val=2147483648, __has_timeout=false, __s=...,
    __ns=...) at ../../../../../src/libstdc++-v3/src/c++11/futex.cc:55
#3 0xafa5c04f in std::__atomic_futex_unsigned<2147483648u>::_M_load_and_test_until (__ns=..., __s=..., __has_timeout=<optimized out>, __mo=<optimized out>,
    __equal=<optimized out>, __operand=<optimized out>, __assumed=<optimized out>, this=<optimized out>) at /usr/include/c++/5/bits/atomic_futex.h:104
#4 std::__atomic_futex_unsigned<2147483648u>::_M_load_and_test (__mo=<optimized out>, __equal=<optimized out>, __operand=<optimized out>,
    __assumed=<optimized out>, this=<optimized out>) at /usr/include/c++/5/bits/atomic_futex.h:122
#5 std::__atomic_futex_unsigned<2147483648u>::_M_load_when_equal (__mo=std::memory_order_acquire, __val=1, this=0xb32f7a9c)
    at /usr/include/c++/5/bits/atomic_futex.h:162
#6 std::__future_base::_State_baseV2::wait (this=0xb32f7a94) at /usr/include/c++/5/future:322
#7 std::__basic_future<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > >::_M_get_result (this=<synthetic pointer>)
    at /usr/include/c++/5/future:681
#8 std::future<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > >::get (this=<synthetic pointer>)
    at /usr/include/c++/5/future:760
#9 unity::lockscreen::UserAuthenticatorPam::ConversationFunction (num_msg=1, msg=0xa7dba0a8, resp=0xa7dba0a4, appdata_ptr=0xa3c4174)
    at /build/unity-G7ZJ7L/unity-7.3.2+15.10.20151016/lockscreen/UserAuthenticatorPam.cpp:151
#10 0xae996243 in pam_vprompt () from /lib/i386-linux-gnu/libpam.so.0
#11 0xae99640c in pam_prompt () from /lib/i386-linux-gnu/libpam.so.0
#12 0xabd24a7e in ?? () from /lib/i386-linux-gnu/security/pam_unix.so
#13 0xabd22093 in pam_sm_authenticate () from /lib/i386-linux-gnu/security/pam_unix.so
#14 0xae991450 in ?? () from /lib/i386-linux-gnu/libpam.so.0
#15 0xae990c7a in pam_authenticate () from /lib/i386-linux-gnu/libpam.so.0
#16 0xafa5a992 in unity::lockscreen::UserAuthenticatorPam::<lambda(GTask*, gpointer, gpointer, GCancellable*)>::operator() (__closure=0x0, task=0x96c56d0,
    data=0xa3c4174) at /build/unity-G7ZJ7L/unity-7.3.2+15.10.20151016/lockscreen/UserAuthenticatorPam.cpp:55
#17 unity::lockscreen::UserAuthenticatorPam::<lambda(GTask*, gpointer, gpointer, GCancellable*)>::_FUN(GTask *, gpointer, gpointer, GCancellable *) ()
    at /build/unity-G7ZJ7L/unity-7.3.2+15.10.20151016/lockscreen/UserAuthenticatorPam.cpp:62
#18 0xb461ec98 in ?? () from /usr/lib/i386-linux-gnu/libgio-2.0.so.0
#19 0xb708c864 in ?? () from /lib/i386-linux-gnu/libglib-2.0.so.0
#20 0xb708be0a in ?? () from /lib/i386-linux-gnu/libglib-2.0.so.0
#21 0xb6ff51aa in start_thread (arg=0xa7dbab40) at pthread_create.c:333
#22 0xb744cfde in clone () at ../sysdeps/unix/sysv/linux/i386/clone.S:122