boostorg / boostorg/fiber

fiber_specific_ptr leaks objects

未关闭
#211 0 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看
主要语言
C++
星标
510
派生
123
PR 合并指标
30 天内没有已合并 PR

描述

## Description
main fiber's fiber_specific_ptr is not correctly cleaned.

## Test Code:
```c++
#include
#include
#include

void clean_fss_int(int* p) {
printf("clean int = %d\n", *p);
}
static boost::fibers::fiber_specific_ptr fs0(clean_fss_int);
static thread_local boost::fibers::fiber_specific_ptr fs1(clean_fss_int);

int main(int argc, char* argv[]) {
boost::fibers::fiber_specific_ptr fs2(clean_fss_int);
auto func = [&](const char* name) {
printf("---- %s ----\n", name);
boost::fibers::fiber_specific_ptr fs3(clean_fss_int);
if (fs0.get() == NULL) {
fs0.reset(new int(0));
}
if (fs1.get() == NULL) {
fs1.reset(new int(1));
}
if (fs2.get() == NULL) {
fs2.reset(new int(2));
}
if (fs3.get() == NULL) {
fs3.reset(new int(3));
}
};
std::thread thr(func, "thread");
thr.join();
boost::fibers::fiber fb(func, "fiber");
fb.join();
return 0;
}
```
## Expected output:
---- thread ----
clean int = 3
clean int = 0
clean int = 1
clean int = 2
---- fiber ----
clean int = 3
clean int = 0
clean int = 1
clean int = 2

## Actual output:
---- thread ----
clean int = 3
clean int = 1
---- fiber ----
clean int = 3
clean int = 0
clean int = 1
clean int = 2

贡献指南

这个仓库没有索引到贡献指南

评估

这个 Issue 还没有评估数据。

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。