jackyf / cupt

high-level package manager for Debian, inspired from APT
36 stars 4 forks source link

Download Manager can deadlock if a signal is received at the wrong time #1

Closed jamessan closed 11 years ago

jamessan commented 11 years ago

During the package download part of a safe-upgrade action, cupt emitted the following error and then just hung:

22% [15 libclang1 394KiB/4605KiB 9%]                      | 1432KiB/s | ETA: 17s
E: download client: the download server socket timed out

Attaching GDB to the parent process of the now zombied downloader shows the following backtrace:

(gdb) bt
#0  0xb76e9430 in __kernel_vsyscall ()
#1  0xb72a6511 in __lll_lock_wait_private () at ../nptl/sysdeps/unix/sysv/linux/i386/i686/../i486/lowlevellock.S:97
#2  0xb72258fb in _L_lock_10900 () at malloc.c:5104
#3  0xb72233c6 in __GI___libc_malloc (bytes=17) at malloc.c:2856
#4  0xb7407395 in operator new(unsigned int) () from /usr/lib/i386-linux-gnu/libstdc++.so.6
#5  0xb7469565 in std::string::_Rep::_S_create(unsigned int, unsigned int, std::allocator<char> const&) () from /usr/lib/i386-linux-gnu/libstdc++.so.6
#6  0xb746b4d6 in char* std::string::_S_construct<char const*>(char const*, char const*, std::allocator<char> const&, std::forward_iterator_tag) ()
#7  0xb746bb60 in std::basic_string<char, std::char_traits<char>, std::allocator<char> >::basic_string(char const*, std::allocator<char> const&) ()
#8  0xb76324fa in cupt::internal::sendPingMessage () at /home/mccoyj1/src/cupt/cpp/lib/src/download/manager.cpp:330
#9  <signal handler called>
#10 _int_malloc (av=av@entry=0xb7355440 <main_arena>, bytes=bytes@entry=16) at malloc.c:3424
#11 0xb72233d3 in __GI___libc_malloc (bytes=16) at malloc.c:2859
#12 0xb7407395 in operator new(unsigned int) () from /usr/lib/i386-linux-gnu/libstdc++.so.6
#13 0xb763ba61 in allocate (__n=<optimized out>, this=<optimized out>) at /usr/include/c++/4.6/ext/new_allocator.h:92
#14 _M_allocate (__n=<optimized out>, this=<optimized out>) at /usr/include/c++/4.6/bits/stl_vector.h:150
#15 std::vector<pollfd, std::allocator<pollfd> >::_M_insert_aux<pollfd>(__gnu_cxx::__normal_iterator<pollfd*, std::vector<pollfd, std::allocator<pollfd> > >,, pollfd&&) (this=0xbf890d90, __position=...) at /usr/include/c++/4.6/bits/vector.tcc:327
#16 0xb7632bbc in emplace_back<pollfd> (this=<optimized out>) at /usr/include/c++/4.6/bits/vector.tcc:102
#17 push_back (__x=..., this=<optimized out>) at /usr/include/c++/4.6/bits/stl_vector.h:840
#18 push_back (__x=..., this=<optimized out>) at /home/mccoyj1/src/cupt/cpp/lib/src/download/manager.cpp:673
#19 cupt::internal::ManagerImpl::pollAllInput (this=0x9a86a80, workerQueue=..., persistentSockets=..., clientSockets=..., exitFlag=false, debugging=false) at /home/mccoyj1/src/cupt/cpp/lib/src/download/manager.cpp:694
#20 0xb76363de in cupt::internal::ManagerImpl::worker (this=0x9a86a80) at /home/mccoyj1/src/cupt/cpp/lib/src/download/manager.cpp:797
#21 0xb7637fc3 in cupt::internal::ManagerImpl::ManagerImpl (this=0x9a86a80, config_=..., progress_=...) at /home/mccoyj1/src/cupt/cpp/lib/src/download/manager.cpp:249
#22 0xb76380dc in cupt::download::Manager::Manager (this=0xbf891140, config=..., progress=...) at /home/mccoyj1/src/cupt/cpp/lib/src/download/manager.cpp:1216
#23 0xb75d4af8 in cupt::internal::PackagesWorker::__do_downloads (this=0x9793904, downloads=..., downloadProgress=...) at /home/mccoyj1/src/cupt/cpp/lib/src/internal/worker/packages.cpp:2000
#24 0xb75db588 in cupt::internal::PackagesWorker::changeSystem (this=0x9793904, downloadProgress=...) at /home/mccoyj1/src/cupt/cpp/lib/src/internal/worker/packages.cpp:2121
#25 0xb762fc09 in cupt::system::Worker::changeSystem (this=0x98dc6b0, progress=...) at /home/mccoyj1/src/cupt/cpp/lib/src/system/worker.cpp:89
#26 0x080f1ca9 in managePackages (context=..., mode=ManagePackages::Install) at /home/mccoyj1/src/cupt/cpp/console/handlers/managepackages.cpp:1321
#27 0x080a2eb3 in operator() (c=..., this=<optimized out>) at /home/mccoyj1/src/cupt/cpp/console/misc.cpp:254
#28 std::_Function_handler<int(Context&), getHandler(const string&)::<lambda(Context&)> >::_M_invoke(const std::_Any_data &, Context &) (__functor=..., __args#0=...) at /usr/include/c++/4.6/functional:1764
#29 0x0809ff55 in operator() (__args#0=..., this=<optimized out>) at /usr/include/c++/4.6/functional:2161
#30 mainEx (argc=3, argv=0xbf8916d4, context=..., command=...) at /home/mccoyj1/src/cupt/cpp/console/cupt.cpp:78
#31 0x0809f922 in main (argc=164371856, argv=0x9af6f10) at /home/mccoyj1/src/cupt/console/cupt.cpp:64
jackyf commented 11 years ago

Many thanks for finding the root issue. This bug is not present in upcoming Cupt 2.6 as alive pings are removed, but also just released 2.5.10 should contain the targeted fix.