stringstream运算符<<崩溃(malloc_consolidate)

时间:2011-01-28 07:20:52

标签: c++ multithreading stl

Program terminated with signal 11, Segmentation fault.
#0  0x0000003663c70485 in malloc_consolidate () from /lib64/libc.so.6
(gdb) bt
#0  0x0000003663c70485 in malloc_consolidate () from /lib64/libc.so.6
#1  0x0000003663c72a6c in _int_malloc () from /lib64/libc.so.6
#2  0x0000003663c74cde in malloc () from /lib64/libc.so.6
#3  0x0000003d364af4aa in operator new(unsigned long) ()
   **/linux2.6-glibc2.3-x86_64/lib64/libstdc++.so.6
#4  0x0000003d364900ee in std::basic_string<char, std::char_traits<char>, std::allocator<char> >::_Rep::_S_create(unsigned long, unsigned long, std::allocator<char> const&) ()
   from **/linux2.6-glibc2.3-x86_64/lib64/libstdc++.so.6

代码是:

...
       if (logger->isEnabledFor(Level::ALL)) {\
            std::ostringstream oss; \
            oss << message; \
            logger->forcedLog(Level::ALL, oss.str(), __FILE__, __LINE__); \
        } \
...

它说,ostringstream的运算符&lt;&lt;不是一个可重新进入的功能。是吗?

由于

1 个答案:

答案 0 :(得分:0)

这应该是因为stringstream :: operator&lt;&lt;是非重入函数。