Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/multithreading/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C++ c++;:不同线程中不同映射上的映射操作是否会导致SIGILL崩溃?_C++_Multithreading_Stl - Fatal编程技术网

C++ c++;:不同线程中不同映射上的映射操作是否会导致SIGILL崩溃?

C++ c++;:不同线程中不同映射上的映射操作是否会导致SIGILL崩溃?,c++,multithreading,stl,C++,Multithreading,Stl,在一个嵌入式ARM系统上,我今天发生了一次奇怪的崩溃,一个map.clear()操作导致了一条非法指令,奇怪的是,一个不同的线程正在访问一个不同的map,但线程堆栈当时使用了类似的stl map函数(std::_RB_tree)。我很好奇是什么导致了这样的事情。线程B中的映射是只读的,尽管我意识到map::operator[]算作写入,但后来我将其更改为.at() 我不相信我以前在代码的这一点上见过崩溃。没有其他线程可以访问任何一个映射 堆栈A: Program received sign

在一个嵌入式ARM系统上,我今天发生了一次奇怪的崩溃,一个map
.clear()
操作导致了一条非法指令,奇怪的是,一个不同的线程正在访问一个不同的map,但线程堆栈当时使用了类似的stl map函数(
std::_RB_tree
)。我很好奇是什么导致了这样的事情。线程B中的映射是只读的,尽管我意识到
map::operator[]
算作写入,但后来我将其更改为
.at()

我不相信我以前在代码的这一点上见过崩溃。没有其他线程可以访问任何一个映射

堆栈A:

   Program received signal SIGILL, Illegal instruction.
[Switching to Thread 1117324432 (LWP 1414)]
0x00433e04 in std::_Rb_tree<SensorEnumType, std::pair<SensorEnumType const, std::string>, std::_Select1st<std::pair<SensorEnumType const, std::string> >, std::less<SensorEnumType>, std::allocator<std::pair<SensorEnumType const, std::string> > >::_M_leftmost (this=0xff0a0000)
    at /opt/freescale/usr/local/gcc-4.1.2-glibc-2.5-nptl-3/arm-none-linux-gnueabi/lib/gcc/arm-none-linux-gnueabi/4.1.2/../../../../include/c++/4.1.2/bits/stl_tree.h:449
449     /opt/freescale/usr/local/gcc-4.1.2-glibc-2.5-nptl-3/arm-none-linux-gnueabi/lib/gcc/arm-none-linux-gnueabi/4.1.2/../../../../include/c++/4.1.2/bits/stl_tree.h: No such file or directory.
        in /opt/freescale/usr/local/gcc-4.1.2-glibc-2.5-nptl-3/arm-none-linux-gnueabi/lib/gcc/arm-none-linux-gnueabi/4.1.2/../../../../include/c++/4.1.2/bits/stl_tree.h
(gdb) bt
#0  0x00433e04 in std::_Rb_tree<SensorEnumType, std::pair<SensorEnumType const, std::string>, std::_Select1st<std::pair<SensorEnumType const, std::string> >, std::less<SensorEnumType>, std::allocator<std::pair<SensorEnumType const, std::string> > >::_M_leftmost (this=0xff0a0000)
    at /opt/freescale/usr/local/gcc-4.1.2-glibc-2.5-nptl-3/arm-none-linux-gnueabi/lib/gcc/arm-none-linux-gnueabi/4.1.2/../../../../include/c++/4.1.2/bits/stl_tree.h:449
#1  0x00434e0c in std::map<SensorEnumType, std::string, std::less<SensorEnumType>, std::allocator<std::pair<SensorEnumType const, std::string> > >::clear (
    this=0x5bd840)
    at /opt/freescale/usr/local/gcc-4.1.2-glibc-2.5-nptl-3/arm-none-linux-gnueabi/lib/gcc/arm-none-linux-gnueabi/4.1.2/../../../../include/c++/4.1.2/bits/stl_map.h:501
#2  0x00430f8c in SensorMap::SensorMapClear (this=0x5bd824,
    maptable=@0x4298f884) at ---
...
程序收到信号信号,指令非法。
[切换到线程1117324432(LWP 1414)]
标准树中的0x00433e04::_Rb_树::_M_最左边(此=0xff0a0000)
在/opt/freescale/usr/local/gcc-4.1.2-glibc-2.5-nptl-3/arm-none-linux-gnueabi/lib/gcc/arm-none-linux-gnueabi/4.1.2/../../../../../../include/c++/4.1.2/bits/stl_-tree.h:449
449/opt/freescale/usr/local/gcc-4.1.2-glibc-2.5-nptl-3/arm-none-linux-gnueabi/lib/gcc/arm-none-linux-gnueabi/4.1.2/../../../../../include/c++/4.1.2/bits/stl_-tree.h:没有这样的文件或目录。
在/opt/freescale/usr/local/gcc-4.1.2-glibc-2.5-nptl-3/arm-none-linux-gnueabi/lib/gcc/arm-none-linux-gnueabi/4.1.2/../../../../../include/c++/4.1.2/bits/stl_-tree.h中
(gdb)英国电信
#标准树中的0 0x00433e04::_Rb_树::_M_最左侧(此=0xff0a0000)
在/opt/freescale/usr/local/gcc-4.1.2-glibc-2.5-nptl-3/arm-none-linux-gnueabi/lib/gcc/arm-none-linux-gnueabi/4.1.2/../../../../../../include/c++/4.1.2/bits/stl_-tree.h:449
#标准::映射::清除中的1 0x00434e0c(
这=0x5bd840)
在/opt/freescale/usr/local/gcc-4.1.2-glibc-2.5-nptl-3/arm-none-linux-gnueabi/lib/gcc/arm-none-linux-gnueabi/4.1.2/../../../../../../include/c++/4.1.2/bits/stl_-map.h:501
#SensorMap::SensorMapClear中的2 0x00430f8c(此=0x5bd824,
maptable=@0x4298f884)在---
...
堆栈B:

[Switching to thread 4 (Thread 1116062864 (LWP 1391))]#0  0x40ca22cc in memcmp
    () from /lib/libc.so.6
(gdb) bt
#0  0x40ca22cc in memcmp () from /lib/libc.so.6
#1  0x40b47dd8 in std::string::compare () from /lib/libstdc++.so.6
#2  0x001e7308 in std::operator< <char, std::char_traits<char>, std::allocator<char> > (__lhs=@0x64e318, __rhs=@0x4285bb50)
    at /opt/freescale/usr/local/gcc-4.1.2-glibc-2.5-nptl-3/arm-none-linux-gnueabi/lib/gcc/arm-none-linux-gnueabi/4.1.2/../../../../include/c++/4.1.2/bits/basic_string.h:2213
#3  0x0039bc70 in std::less<std::string>::operator() (this=0x5c4f40,
    __x=@0x64e318, __y=@0x4285bb50)
    at /opt/freescale/usr/local/gcc-4.1.2-glibc-2.5-nptl-3/arm-none-linux-gnueabi/lib/gcc/arm-none-linux-gnueabi/4.1.2/../../../../include/c++/4.1.2/bits/stl_function.h:227
#4  0x0041bd7c in std::_Rb_tree<std::string, std::pair<std::string const, datalogDefTableRow>, std::_Select1st<std::pair<std::string const, datalogDefTableRow> >, std::less<std::string>, std::allocator<std::pair<std::string const, datalogDefTableRow> > >::lower_bound (this=0x5c4f40, __k=@0x4285bb50)
    at /opt/freescale/usr/local/gcc-4.1.2-glibc-2.5-nptl-3/arm-none-linux-gnueabi/lib/gcc/arm-none-linux-gnueabi/4.1.2/../../../../include/c++/4.1.2/bits/stl_tree.h:1371
#5  0x0041be6c in std::map<std::string, datalogDefTableRow, std::less<std::string>, std::allocator<std::pair<std::string const, datalogDefTableRow> > >::lower_bound (this=0x5c4f40, __x=@0x4285bb50)
    at /opt/freescale/usr/local/gcc-4.1.2-glibc-2.5-nptl-3/arm-none-linux-gnueab---Type <return> to continue, or q <return> to quit---
i/lib/gcc/arm-none-linux-gnueabi/4.1.2/../../../../include/c++/4.1.2/bits/stl_map.h:576
#6  0x0041e738 in std::map<std::string, datalogDefTableRow, std::less<std::string>, std::allocator<std::pair<std::string const, datalogDefTableRow> > >::operator[] (this=0x5c4f40, __k=@0x4285bb50)
    at /opt/freescale/usr/local/gcc-4.1.2-glibc-2.5-nptl-3/arm-none-linux-gnueabi/lib/gcc/arm-none-linux-gnueabi/4.1.2/../../../../include/c++/4.1.2/bits/stl_map.h:345
#7  0x003f18cc in getDatalogTableRow (item=@0x4285bb50, row=@0x4285baf0)
    at ---
...
[切换到线程4(线程1116062864(LWP 1391))]#0 memcmp中的0x40ca22cc
()来自/lib/libc.so.6
(gdb)英国电信
#/lib/libc.so.6中的memcmp()中0 0x40ca22cc
#来自/lib/libstdc++.so.6的std::string::compare()中的1 0x40b47dd8
#2个0x001e7308标准::运算符<(uuu lhs=@0x64e318,uuu rhs=@0x4285bb50)
在/opt/freescale/usr/local/gcc-4.1.2-glibc-2.5-nptl-3/arm-none-linux-gnueabi/lib/gcc/arm-none-linux-gnueabi/4.1.2/../../../../../../include/c++/4.1.2/bits/basic_string.h:2213
#std::less::operator()中的3 0x0039bc70(此=0x5c4f40,
__x=@0x64e318,uu y=@0x4285bb50)
at/opt/freescale/usr/local/gcc-4.1.2-glibc-2.5-nptl-3/arm-none-linux-gnueabi/lib/gcc/arm-none-linux-gnueabi/4.1.2/../../../../../../include/c++/4.1.2/bits/stl_function.h:227
#标准中的4 0x0041bd7c::_Rb_树::下限(this=0x5c4f40,u_k=@0x4285bb50)
在/opt/freescale/usr/local/gcc-4.1.2-glibc-2.5-nptl-3/arm-none-linux-gnueabi/lib/gcc/arm-none-linux-gnueabi/4.1.2/../../../../../../include/c++/4.1.2/bits/stl_-tree.h:1371
#std::map::lower_bound中的5 0x0041be6c(this=0x5c4f40,_x=@0x4285bb50)
在/opt/freescale/usr/local/gcc-4.1.2-glibc-2.5-nptl-3/arm-none-linux-gnueab--Type继续,或键入q退出---
i/lib/gcc/arm none-linux-gnueabi/4.1.2/../../../../../../../include/c++/4.1.2/bits/stl_-map.h:576
#std::map::operator[]中的6 0x0041e738(this=0x5c4f40,_k=@0x4285bb50)
在/opt/freescale/usr/local/gcc-4.1.2-glibc-2.5-nptl-3/arm-none-linux-gnueabi/lib/gcc/arm-none-linux-gnueabi/4.1.2/../../../../../../include/c++/4.1.2/bits/stl_-map.h:345
#getDatalogTableRow中的7 0x003f18cc(项=@0x4285bb50,行=@0x4285baf0)
在---
...
任何见解都值得赞赏