这个正确的示例导致std::cout
行中的段错误与特定的编译参数:
#include <exception>
#include <iostream>
int main(int argc, char** argv) {
try {
throw std::runtime_error("BLA");
} catch (const std::exception& exception) {
std::cout << exception.what() << std::endl;
}
}
仅在使用gcc-7.2和Intel TBB在OS X上进行编译时才会出现:
g++-7 exception.cpp /usr/local/lib/libtbb.dylib
由于TBB的OS X版本是使用clang构建的并且与libc ++链接,我尝试使用来自repo的g ++ - 7构建它。这不会改变任何事情。此外,参数的顺序无关紧要。
在Ubuntu上,一切都很好。
这感觉就像某个地方的错误,但我不确定在哪里。有关如何解决此问题或在何处提交错误的任何想法?我还在TBB论坛中开辟了thread。
可能有用的更多信息:
堆栈跟踪
* thread #1, queue = 'com.apple.main-thread', stop reason = EXC_BAD_ACCESS (code=EXC_I386_GPFLT)
frame #0: 0x0000000100000da1 a.out`main(argc=1, argv=0x00007fff5fbff880) at exception.cpp:8
5 try {
6 throw std::runtime_error("BLA");
7 } catch (const std::exception& exception) {
-> 8 std::cout << exception.what() << std::endl;
9 }
10 }
版本
[:~/tmp] $ g++-7 --version
g++-7 (Homebrew GCC 7.2.0) 7.2.0
[:~/tmp] $ brew info tbb
tbb: stable 2018_U1 (bottled)
[:~/tmp] $ sw_vers -productVersion
10.12.6
ASAN
ASAN:DEADLYSIGNAL
=================================================================
==9698==ERROR: AddressSanitizer: SEGV on unknown address 0x000000000000 (pc 0x000104c03b22 bp 0x7fff5affc940 sp 0x7fff5affc900 T0)
==9698==The signal is caused by a READ memory access.
==9698==Hint: address points to the zero page.
#0 0x104c03b21 in main (/Users/markus/tmp/./a.out+0x100000b21)
#1 0x7fffa9734234 in start (/usr/lib/system/libdyld.dylib+0x5234)
AddressSanitizer can not provide additional info.
SUMMARY: AddressSanitizer: SEGV (/Users/markus/tmp/./a.out+0x100000b21) in main
==9698==ABORTING
Abort trap: 6