Cafe OS Sanity Checks

Introduction

In general, applications should be run in DEBUG mode on a regular basis because Cafe OS includes numerous important runtime checks that can help find bugs earlier and more easily than in NDEBUG mode.

Further checks must be enabled explicitly when an application is invoked. For example, the data structure sanity checks below are enabled by running the application with "caferun -v 2". Applications should also be run in this mode on a regular basis.

Data Structure Sanity Checks

Beginning with SDK 2.08.04, Cafe OS includes new sanity checks for its data structures, many of which can be directly or indirectly manipulated by the application. The sanity checks cause assertion failures when they fail, making it easier to pinpoint the source of the issue.

In SDK 2.08.04, these sanity checks were always enabled in the DEBUG builds of Cafe OS.

Beginning with SDK 2.08.05, the checks are disabled by default, but can be enabled by invoking the application with "caferun -v 2".

The checks are always disabled in NDEBUG builds of Cafe OS.

Available Sanity Checks

When enabled, the data structure sanity checks cause assertion failures when certain types of corruption are detected. The checks include:

  1. When locking, unlocking or otherwise using any of the OSContext, OSEvent, OSMessageQueue, OSMutex, OSCond, and OSSemaphore structures:
    • Verify that an OSContext, OSEvent, OSMessageQueue, OSMutex, OSCond, and OSSemaphore was initialized with the appropriate OSInit* function call before use.
      NOTE:
      Initializing these structures by setting them to zero explicitly or by locating them in BSS is not sufficient.
    • Verify that the data in the structures are consistent with no indication of corruption.
  2. Verify that the start of an OSContext is not corrupted before resuming the thread via the user-mode scheduler.
  3. Every 4ms, Cafe OS runs the OSCheckActiveThreads function on Core 2 to ensure that the global thread list has not been corrupted and that items referenced by the thread list are also intact.

Revision History

2013/05/08 Automated cleanup pass.
2012/11/01 Initial version.


CONFIDENTIAL