DEVELOPMENT EDITION · 769442725406
Diagnostics Reference
On this page

B6011: use of an enclave's cell after it is freed

Catalog status: active. Default severity: error. Stable name: dangling-cell. Family: Ownership and finalization.

A proof enclave's body shares cells between pointers. What the heap engine has not proved of it (its frames, when one of its types keeps no footprint, and whatever a build without proof or an advisory run leaves to be checked as the program runs) is trusted. So that a mistake there is a failed check rather than a corruption, its cells come from a checking allocator: each cell records whether it is live, a freed cell is poisoned and kept out of reuse, and every read or write through one of the enclave's pointers first checks that the cell it designates has not been freed. This is a run-time check: the program stops where a freed cell is used. (A pointer to a cell freed long before, beyond the last 64 MB of freed cells, may go undetected.)

Example (Vada)

   procedure Pop (S : in out Stack; X : out Integer) is
      Old : Node_Ptr := S.Top;
   begin
      Free (Old);
      X := S.Top.Value;   --  S.Top still designates the freed cell
      ...

What to do (Vada)

Read what you need from a cell before freeing it, and move every pointer that designates it off it first:

      X := S.Top.Value;
      S.Top := S.Top.Next;
      Free (Old);

Regression source and further reading

Complete regression example: source, command arguments and expected results. The fixture deliberately reproduces this diagnostic.

See ownership and finalization, the code index, and diagnostic interpretation for modes, replay, fix-its and JSON.