libgo icon indicating copy to clipboard operation
libgo copied to clipboard

静态局部变量初始化会出现死锁

Open wnxd opened this issue 5 years ago • 2 comments

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

wnxd avatar Dec 05 '19 09:12 wnxd

协程中 std::call_once 的使用也有一些问题

wnxd avatar Dec 05 '19 10:12 wnxd

你能把你完整的测试代码放上来吗,我运行你上面的测试代码,没出现你说的情况。只是死循环创建协程,把内存耗尽了

sunny-shu avatar Aug 27 '20 11:08 sunny-shu