Reset es_action field when idle ws engine receives a notification.

In MR_do_idle_worksteal, reset the engine's es_action field to
MR_ENGINE_ACTION_NONE before performing the notified action.
This mirrors the behaviour in MR_do_sleep.

Fixes the assertion failure in Mantis bug #461: when an engine is
shut down, MR_verify_final_engine_sleep_sync checks that the engine's
es_action field is MR_ENGINE_ACTION_NONE.

runtime/mercury_context.c:
    As above.

NEWS:
    Announce change.
This commit is contained in:
Peter Wang
2020-04-20 12:41:45 +10:00
parent 5a233ef782
commit a4b26739ba
2 changed files with 7 additions and 1 deletions

3
NEWS
View File

@@ -263,6 +263,9 @@ Changes to the Mercury implementation
* We have upgraded the bundled Boehm GC to v7.6.12 and libatomic_ops to v7.6.8.
* [Mantis bug #461]. We have fixed an assertion failure affecting programs
in low-level C parallel grades as they exit.
NEWS for Mercury 20.01.2
========================

View File

@@ -2279,6 +2279,7 @@ MR_define_entry(MR_do_idle_worksteal);
MR_Code *jump_target;
MR_EngineId engine_id = MR_ENGINE(MR_eng_id);
engine_sleep_sync *esync = get_engine_sleep_sync(engine_id);
unsigned action;
// Only work-stealing engines beyond this point.
MR_assert(MR_ENGINE(MR_eng_type) == MR_ENGINE_TYPE_SHARED);
@@ -2290,8 +2291,10 @@ MR_define_entry(MR_do_idle_worksteal);
}
// The compare and swap failed, which means there is a notification.
action = esync->d.es_action;
esync->d.es_action = MR_ENGINE_ACTION_NONE;
switch (esync->d.es_action) {
switch (action) {
case MR_ENGINE_ACTION_SHUTDOWN:
action_shutdown_ws_engine();