facebook / facebook/folly

Segmentation fault when using coro::Generator, coro::Task and CPUTreadpoolExecutor

Open
#1,841 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
C++
Stars
30.5k
Forks
5.9k
PR merge metrics
No merged PRs in 30d

Description

Hi guys, I'm trying to use folly::coro in my project to get better performance, but this error has bothered me for a long time, here is the code that reproduces the error:

```
#include
#include
#include
#include
#include
#include
#include

using namespace std;

static auto exec = std::make_shared(
100,
std::make_shared("Exec."));
atomic a = 0;

folly::coro::Generator::iterator iter;

void foo () {
iter++;
}

folly::coro::Task fooTask () {
iter++;
co_return;
}

folly::coro::Generator
gene (int h) {
atomic i = 0;
atomic f = false;

for (; i < h; i++) {
cout << i << endl;
co_yield i;
}
if (f) {
cout << "double exec";
}
f = true;
cout << "complete" </dev/null || break;done
```
to reproduce.

Contributor guide

Open the contributing guide

Research direction

Build and run the supplied reproducer, including the repeated shell loop, then inspect folly/experimental/coro/Generator.h, folly/experimental/coro/Task.h, and CPUThreadPoolExecutor.h. Trace the interaction between the generator iterator, scheduled tasks, and executor threads. Done means the reproducer no longer intermittently segfaults under repeated execution.

Written by the indexing model from the issue text.

Assessment

Tech stack
cpp
Domain
backend
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.