Почему std :: thread core dump при использовании переменных шаблонов в качестве argv - PullRequest
0 голосов
/ 31 мая 2019

Я хотел бы знать, почему std::thread заканчивается в дампе ядра при использовании переменных шаблонов как argv.Спасибо.

    #0  0x00007ffff71b0207 in __GI_raise (sig=sig@entry=6) at ../nptl/sysdeps/unix/sysv/linux/raise.c:55
    #1  0x00007ffff71b18f8 in __GI_abort () at abort.c:90
    #2  0x00007ffff7aed8cd in __gnu_cxx::__verbose_terminate_handler () at ../../../../gcc-5.3.0/libstdc++-v3/libsupc++/vterminate.cc:95
    #3  0x00007ffff7aeb906 in __cxxabiv1::__terminate (handler=<optimized out>) at ../../../../gcc-5.3.0/libstdc++-v3/libsupc++/eh_terminate.cc:47
    #4  0x00007ffff7aeb951 in std::terminate () at ../../../../gcc-5.3.0/libstdc++-v3/libsupc++/eh_terminate.cc:57
    #5  0x00007ffff7aebb69 in __cxxabiv1::__cxa_throw (obj=obj@entry=0x618dd0, tinfo=0x7ffff7dcdc00 <typeinfo for std::system_error>, dest=0x7ffff7b15340 <std::system_error::~system_error()>)
        at ../../../../gcc-5.3.0/libstdc++-v3/libsupc++/eh_throw.cc:87
    #6  0x00007ffff7b15baa in std::thread::_M_start_thread (this=<optimized out>, __b=...) at ../../../../../gcc-5.3.0/libstdc++-v3/src/c++11/thread.cc:135
    #7  0x0000000000401bfb in std::thread::thread<int (&)(_mem_delegateZ<t, int, int, int>&, int&&, int&&), std::reference_wrapper<_mem_delegateZ<t, int, int, int> >, int, int>(int (&)(_mem_delegateZ<t, int, int, int>&, int&&, int&&), std::reference_wrapper<_mem_delegateZ<t, int, int, int> >&&, int&&, int&&) (this=0x7fffffffde30, __f=
        @0x401a74: {int (_mem_delegateZ<t, int, int, int> &, <unknown type in /home/oracle/test/test2, CU 0x0, DIE 0x919e>, <unknown type in /home/oracle/test/test2, CU 0x0, DIE 0x91a3>)} 0x401a74 <threadPool<t, int, int, int>::wrap(_mem_delegateZ<t, int, int, int>&, int&&, int&&)>) at /usr/include/c++/4.8.2/thread:135
    #8  0x00000000004018a8 in threadPool<t, int, int, int>::run(int, int&&, int&&) (this=0x7fffffffdec0, id=0, args#0=<unknown type in /home/oracle/test/test2, CU 0x0, DIE 0x9f25>, 
        args#1=<unknown type in /home/oracle/test/test2, CU 0x0, DIE 0x9f25>) at threadPool.h:40
    #9  0x0000000000401413 in threadPool<t, int, int, int>::createNewThread(int&&, int&&) (this=0x7fffffffdec0, argv#0=<unknown type in /home/oracle/test/test2, CU 0x0, DIE 0x9f25>, 
        argv#1=<unknown type in /home/oracle/test/test2, CU 0x0, DIE 0x9f25>) at threadPool.h:105
    #10 0x0000000000400e29 in main () at test2.cpp:14
    (gdb) f 9
    #9  0x0000000000401413 in threadPool<t, int, int, int>::createNewThread(int&&, int&&) (this=0x7fffffffdec0, argv#0=<unknown type in /home/oracle/test/test2, CU 0x0, DIE 0x9f25>, 
        argv#1=<unknown type in /home/oracle/test/test2, CU 0x0, DIE 0x9f25>) at threadPool.h:105
        static R wrap(_mem_delegateZ<T, R, P...> &d,P&&... args)
        {
                return d(std::forward<P>(args) ...);
        }
        bool run(int id,P&&...args)
        {
                char status = T_IDLE;
                if (m_threadStatus[id].compare_exchange_strong(status, T_RUNNING))
                {
                        if (++m_currentThreadCount > m_currentMaxThreads)
                        {
                                m_currentThreadCount--;
                                m_threadStatus[id] = T_IDLE;
                                return false;
                        }
                        m_threads[id] = std::thread(wrap, std::ref(m_delegate), std::forward<P>(args) ...);
                        return true;
                }
                else
                        return false;
        }

...