//===-- msan_origin.h ----------------------------------*- C++ -*-===// // // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. // See https://llvm.org/LICENSE.txt for license information. // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// // // Origin id utils. //===----------------------------------------------------------------------===// #ifndef MSAN_ORIGIN_H #define MSAN_ORIGIN_H #include "sanitizer_common/sanitizer_stackdepot.h" #include "msan_chained_origin_depot.h" namespace __msan { // Origin handling. // // Origin is a 32-bit identifier that is attached to any uninitialized value in // the program and describes, more or less exactly, how this memory came to be // uninitialized. // // There are 3 kinds of origin ids: // 1xxx xxxx xxxx xxxx heap origin id // 0000 xxxx xxxx xxxx stack origin id // 0zzz xxxx xxxx xxxx chained origin id // // Heap origin id describes a heap memory allocation and contains (in the xxx // part) a value of StackDepot. // // Stack origin id describes a stack memory allocation and contains (in the xxx // part) an index into StackOriginDescr and StackOriginPC. We don't store a // stack trace for such origins for performance reasons. // // Chained origin id describes an event of storing an uninitialized value to // memory. The xxx part is a value of ChainedOriginDepot, which is a mapping of // (stack_id, prev_id) -> id, where // * stack_id describes the event. // StackDepot keeps a mapping between those and corresponding stack traces. // * prev_id is another origin id that describes the earlier part of the // uninitialized value history. // Following a chain of prev_id provides the full recorded history of an // uninitialized value. // // This, effectively, defines a tree (or 2 trees, see below) where nodes are // points in value history marked with origin ids, and edges are events that are // marked with stack_id. // // The "zzz" bits of chained origin id are used to store the length (or depth) // of the origin chain. class Origin { … }; } // namespace __msan #endif // MSAN_ORIGIN_H