HomePhabricator

Fix consistency issue with cross-context cycle exceptions

Description

Fix consistency issue with cross-context cycle exceptions

enterContext() throws an exception when cross-context cycle is found.
The problem is that it modifies state before the exception is thrown,
assuming that the call will succeed.

When an exception is thrown, a dependency is left in invalid state, with
parent being in more specific context. This breaks exitContext()
algorithm and results in either internal invariant violations as seen
in #2091939, or memory corruptions and crashes as seen in #2125762.

Let's fix it by modifying state after returning back from recursive call
instead of before doing such call. This was previously unsafe in case we
tried to import dependency loop. Once D720506 is committed, dependency
loops will not exist anymore.

Details

Provenance
janAuthored on
Sara GolemonCommitted on Mar 6 2013, 6:28 AM
Parents
rOSHDc6475efbec20: Detect cycles online and fix part of #2125762
Branches
Unknown
Tags
Unknown
ChangeId
None