Inconsistent ordering in AtFork's prepare() rollback vs parent() execution
- Dominant language
- C++
- Stars
- 30.5k
- Forks
- 5.9k
- PR merge metrics
- No merged PRs in 30d
Description
In the AtFork implementation, there appears to be an inconsistency in the ordering of handler execution between the rollback in `prepare()` and the execution in `parent()`.
When a prepare handler fails, the code needs to rollback previously successful prepare handlers. Currently, this is done in reverse order:
https://github.com/facebook/folly/blob/main/folly/system/AtFork.cpp#L40
```cpp
for (auto untask = tasks.rbegin(); untask != task; ++untask) {
if (auto& f = untask->parent) {
f();
}
}
```
However, in the `Parent()` function, handlers are executed in forward order:
https://github.com/facebook/folly/blob/main/folly/system/AtFork.cpp#L52
```cpp
for (auto& task : tasks) {
if (auto& f = task.parent) {
f();
}
}
```
Can anyone tell me the reason?
Contributor guide
Assessment
This issue has not been assessed yet.