在ubuntu 16.04操作系统上使用g ++编译器执行多线程c ++代码(标题为DSDMultiplexer);该程序会引发分段错误并中止。
GDB调试;经过很长一段时间后,我得到了这个:
(gdb) info thread
Id Target Id Frame
1 Thread 0x7ffff7fd8740 (LWP 7078) "DSDMultiplexer" 0x00007ffff704624d in read () at ../sysdeps/unix/syscall-template.S:84
2 Thread 0x7fffedbaa700 (LWP 7084) "DSDMultiplexer" (Exiting) 0x00007ffff732976d in accept () at ../sysdeps/unix/syscall-template.S:84
3 Thread 0x7fffed3a9700 (LWP 7085) "DSDMultiplexer" 0x00007ffff701b30d in nanosleep () at ../sysdeps/unix/syscall-template.S:84
4 Thread 0x7fffecba8700 (LWP 7086) "DSDMultiplexer" 0x00007ffff701b30d in nanosleep () at ../sysdeps/unix/syscall-template.S:84
5 Thread 0x7fffe7fff700 (LWP 7087) "DSDMultiplexer" __lll_lock_wait_private () at ../sysdeps/unix/sysv/linux/x86_64/lowlevellock.S:95
6 Thread 0x7fffe77fe700 (LWP 7095) "DSDMultiplexer" __lll_lock_wait_private () at ../sysdeps/unix/sysv/linux/x86_64/lowlevellock.S:95
7 Thread 0x7fffe6ffd700 (LWP 7096) "DSDMultiplexer" __lll_lock_wait_private () at ../sysdeps/unix/sysv/linux/x86_64/lowlevellock.S:95
8 Thread 0x7fffe67fc700 (LWP 7107) "DSDMultiplexer" 0x00007ffff7057567 in socket () at ../sysdeps/unix/syscall-template.S:84
9 Thread 0x7fffe5ffb700 (LWP 7112) "DSDMultiplexer" __GI___uflow (fp=0x7fffe5ffa860) at genops.c:350
10 Thread 0x7fffe57fa700 (LWP 7119) "DSDMultiplexer" __lll_lock_wait_private () at ../sysdeps/unix/sysv/linux/x86_64/lowlevellock.S:95
11 Thread 0x7fffe4ff9700 (LWP 7134) "DSDMultiplexer" __lll_lock_wait_private () at ../sysdeps/unix/sysv/linux/x86_64/lowlevellock.S:95
12 Thread 0x7fffd3fff700 (LWP 7151) "DSDMultiplexer" __lll_lock_wait_private () at ../sysdeps/unix/sysv/linux/x86_64/lowlevellock.S:95
13 Thread 0x7fffd37fe700 (LWP 7159) "DSDMultiplexer" __lll_lock_wait_private () at ../sysdeps/unix/sysv/linux/x86_64/lowlevellock.S:95
14 Thread 0x7fffd2ffd700 (LWP 7175) "DSDMultiplexer" __lll_lock_wait_private () at ../sysdeps/unix/sysv/linux/x86_64/lowlevellock.S:95
15 Thread 0x7fffd27fc700 (LWP 7190) "DSDMultiplexer" __lll_lock_wait_private () at ../sysdeps/unix/sysv/linux/x86_64/lowlevellock.S:95
* 16 Thread 0x7fffd1ffb700 (LWP 7205) "DSDMultiplexer" __libc_disable_asynccancel () at ../sysdeps/unix/sysv/linux/x86_64/cancellation.S:90
17 Thread 0x7fffd17fa700 (LWP 7215) "DSDMultiplexer" 0x00007ffff701b30d in nanosleep () at ../sysdeps/unix/syscall-template.S:84
18 Thread 0x7fffd0ff9700 (LWP 7216) "DSDMultiplexer" DSDPSIinsert::RemapPAT (this=this@entry=0x7fffd0fee44f, Cfg=Cfg@entry=0x7fffedf71010,
PSIG=PSIG@entry=0x7fffedbab010, m_Adi=m_Adi@entry=0x677560, no_of_ports=no_of_ports@entry=12) at DSDPSIinsert.cpp:33
19 Thread 0x7fffbffff700 (LWP 7226) "DSDMultiplexer" 0x00007ffff701b30d in nanosleep () at ../sysdeps/unix/syscall-template.S:84
(gdb) s
91 in ../sysdeps/unix/sysv/linux/x86_64/cancellation.S
(gdb) s
93 in ../sysdeps/unix/sysv/linux/x86_64/cancellation.S
(gdb) s
Thread 2 "DSDMultiplexer" received signal SIGSEGV, Segmentation fault.
[Switching to Thread 0x7fffedbaa700 (LWP 7084)]
0x0000007b0000007b in ?? ()
(gdb) info thread
Id Target Id Frame
1 Thread 0x7ffff7fd8740 (LWP 7078) "DSDMultiplexer" 0x00007ffff704624d in read () at ../sysdeps/unix/syscall-template.S:84
* 2 Thread 0x7fffedbaa700 (LWP 7084) "DSDMultiplexer" (Exiting) 0x0000007b0000007b in ?? ()
3 Thread 0x7fffed3a9700 (LWP 7085) "DSDMultiplexer" 0x00007ffff701b30d in nanosleep () at ../sysdeps/unix/syscall-template.S:84
4 Thread 0x7fffecba8700 (LWP 7086) "DSDMultiplexer" 0x00007ffff701b30d in nanosleep () at ../sysdeps/unix/syscall-template.S:84
5 Thread 0x7fffe7fff700 (LWP 7087) "DSDMultiplexer" 0x00007ffff7045bb5 in __GI___xstat (vers=vers@entry=1,
name=name@entry=0x7ffff70dd127 "/etc/localtime", buf=buf@entry=0x7fffe7ffea60) at ../sysdeps/unix/sysv/linux/wordsize-64/xstat.c:35
6 Thread 0x7fffe77fe700 (LWP 7095) "DSDMultiplexer" __lll_lock_wait_private () at ../sysdeps/unix/sysv/linux/x86_64/lowlevellock.S:95
7 Thread 0x7fffe6ffd700 (LWP 7096) "DSDMultiplexer" __lll_lock_wait_private () at ../sysdeps/unix/sysv/linux/x86_64/lowlevellock.S:95
8 Thread 0x7fffe67fc700 (LWP 7107) "DSDMultiplexer" __lll_lock_wait_private () at ../sysdeps/unix/sysv/linux/x86_64/lowlevellock.S:95
9 Thread 0x7fffe5ffb700 (LWP 7112) "DSDMultiplexer" __lll_lock_wait_private () at ../sysdeps/unix/sysv/linux/x86_64/lowlevellock.S:95
10 Thread 0x7fffe57fa700 (LWP 7119) "DSDMultiplexer" __lll_lock_wait_private () at ../sysdeps/unix/sysv/linux/x86_64/lowlevellock.S:95
11 Thread 0x7fffe4ff9700 (LWP 7134) "DSDMultiplexer" __lll_lock_wait_private () at ../sysdeps/unix/sysv/linux/x86_64/lowlevellock.S:95
12 Thread 0x7fffd3fff700 (LWP 7151) "DSDMultiplexer" __lll_lock_wait_private () at ../sysdeps/unix/sysv/linux/x86_64/lowlevellock.S:95
13 Thread 0x7fffd37fe700 (LWP 7159) "DSDMultiplexer" __lll_lock_wait_private () at ../sysdeps/unix/sysv/linux/x86_64/lowlevellock.S:95
14 Thread 0x7fffd2ffd700 (LWP 7175) "DSDMultiplexer" __lll_lock_wait_private () at ../sysdeps/unix/sysv/linux/x86_64/lowlevellock.S:95
15 Thread 0x7fffd27fc700 (LWP 7190) "DSDMultiplexer" __lll_lock_wait_private () at ../sysdeps/unix/sysv/linux/x86_64/lowlevellock.S:95
16 Thread 0x7fffd1ffb700 (LWP 7205) "DSDMultiplexer" __libc_disable_asynccancel () at ../sysdeps/unix/sysv/linux/x86_64/cancellation.S:94
17 Thread 0x7fffd17fa700 (LWP 7215) "DSDMultiplexer" 0x00007ffff7b63e3e in std::basic_ostream<char, std::char_traits<char> >& std::__ostream_insert<char, std::char_traits<char> >(std::basic_ostream<char, std::char_traits<char> >&, char const*, long) ()
from /usr/lib/x86_64-linux-gnu/libstdc++.so.6
18 Thread 0x7fffd0ff9700 (LWP 7216) "DSDMultiplexer" DSDPSIinsert::RemapPAT (this=this@entry=0x7fffd0fee44f, Cfg=Cfg@entry=0x7fffedf71010,
PSIG=PSIG@entry=0x7fffedbab010, m_Adi=m_Adi@entry=0x677560, no_of_ports=no_of_ports@entry=12) at DSDPSIinsert.cpp:33
19 Thread 0x7fffbffff700 (LWP 7226) "DSDMultiplexer" 0x00007ffff701b30d in nanosleep () at ../sysdeps/unix/syscall-template.S:84
(gdb) step
Cannot find bounds of current function
(gdb)
Cannot find bounds of current function
(gdb)
Cannot find bounds of current function
(gdb)
Cannot find bounds of current function
(gdb)
Cannot find bounds of current function
我无法发布整个gdb输出;由于charachter限制;但是here's你可以通过谷歌驱动器访问它。
正如您将看到具有Id 2的线程生成分段错误。
此线程也始终在(gdb)info thread
2 Thread 0x7fffedbaa700 (LWP 7084) "DSDMultiplexer" 0x00007ffff732976d in accept () at ../sysdeps/unix/syscall-template.S:84
源代码是巨大的,我无法重现StackExchange所要求的Minimal,Complete和Verifiable示例。
我的应用程序代码是否达到了一个突破点 - 深入内部 标准C库(aka glibc)?