HomePhabricator

Access context by index

Description

Access context by index

Currently, wait handles store pointer to the context they are in. This
pointer is not protected with reference counting, as it is expected that
whenever a context is exited, references to it are cleaned thru
exitContext() mechanism.

If a bug is present that violates this assumption, it is impossible to
guard against invalid pointer access and a hard to debug memory
corruption occurs.

Since the structure of contexts is a simple stack, let's reference them
by index instead of by pointer.

As a bonus, one pointer worth of memory is saved for every non-trivial wait handle.

The actual bugs will be fixed by the next 2 diffs that do:

  1. implement online cycle detection
  2. do enterContext() atomically and properly handle failure

Details

Provenance
janAuthored on
Sara GolemonCommitted on Mar 6 2013, 6:28 AM
Parents
rOSHD0562656c5b00: Rename some tests to avoid collisions on case-insensitive filesystems.
Branches
Unknown
Tags
Unknown
ChangeId
None

Event Timeline