libgo
libgo copied to clipboard
静态局部变量初始化会出现死锁
std::vector<std::string> xxx() {
// libcurl get http://xxxx;
std::string response;
std::vector<std::string> list = string_split(response, "\n");
return list;
}
void test() {
static std::vector<std::string> list = xxx();
或者
static SQLite::Database db("xxx.db", SQLite::OPEN_READWRITE);
// ...
}
for (;;)
go test;
会导致 libc++abi.dylib: __cxa_guard_acquire detected deadlock
协程中 std::call_once 的使用也有一些问题
你能把你完整的测试代码放上来吗,我运行你上面的测试代码,没出现你说的情况。只是死循环创建协程,把内存耗尽了