You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
map_reduce: prevent mapper or reducer exception from poisoning state
In map_reduce, if the mapper throws, we can end up with poisoned
state. This is because the compiler can choose to move s->result
before evaluating f.get(), so s->result gets broken (if the mapped
type becomes invalid after move).
Fix by checking for exceptions from the mapper before calling the reducer,
and exceptions from the reducer after calling the reducer, and storing them
in the state. If we see an exception, don't bother calling the reducer on
failed state. Since the reducer is a pure function (at least in expected
usage), and wouldn't have been called on mapper exceptions, we don't lose
anything by calling it.
A unit test is added for mapper exceptions and for reducer exceptions.
The tests do fail with clang before the patch, though if the arguments
are evaluated in reverse order, it can pass with a different compiler).
0 commit comments