llvm/compiler-rt/lib/scudo/standalone/report.cpp

//===-- report.cpp ----------------------------------------------*- 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
//
//===----------------------------------------------------------------------===//

#include "report.h"

#include "atomic_helpers.h"
#include "string_utils.h"

#include <stdarg.h>

namespace scudo {

class ScopedErrorReport {};

inline void NORETURN trap() {}

// This could potentially be called recursively if a CHECK fails in the reports.
void NORETURN reportCheckFailed(const char *File, int Line,
                                const char *Condition, u64 Value1, u64 Value2) {}

// Generic string fatal error message.
void NORETURN reportError(const char *Message) {}

// Generic fatal error message without ScopedString.
void NORETURN reportRawError(const char *Message) {}

void NORETURN reportInvalidFlag(const char *FlagType, const char *Value) {}

// The checksum of a chunk header is invalid. This could be caused by an
// {over,under}write of the header, a pointer that is not an actual chunk.
void NORETURN reportHeaderCorruption(void *Ptr) {}

// The allocator was compiled with parameters that conflict with field size
// requirements.
void NORETURN reportSanityCheckError(const char *Field) {}

// We enforce a maximum alignment, to keep fields smaller and generally prevent
// integer overflows, or unexpected corner cases.
void NORETURN reportAlignmentTooBig(uptr Alignment, uptr MaxAlignment) {}

// See above, we also enforce a maximum size.
void NORETURN reportAllocationSizeTooBig(uptr UserSize, uptr TotalSize,
                                         uptr MaxSize) {}

void NORETURN reportOutOfBatchClass() {}

void NORETURN reportOutOfMemory(uptr RequestedSize) {}

static const char *stringifyAction(AllocatorAction Action) {}

// The chunk is not in a state congruent with the operation we want to perform.
// This is usually the case with a double-free, a realloc of a freed pointer.
void NORETURN reportInvalidChunkState(AllocatorAction Action, void *Ptr) {}

void NORETURN reportMisalignedPointer(AllocatorAction Action, void *Ptr) {}

// The deallocation function used is at odds with the one used to allocate the
// chunk (eg: new[]/delete or malloc/delete, and so on).
void NORETURN reportDeallocTypeMismatch(AllocatorAction Action, void *Ptr,
                                        u8 TypeA, u8 TypeB) {}

// The size specified to the delete operator does not match the one that was
// passed to new when allocating the chunk.
void NORETURN reportDeleteSizeMismatch(void *Ptr, uptr Size,
                                       uptr ExpectedSize) {}

void NORETURN reportAlignmentNotPowerOfTwo(uptr Alignment) {}

void NORETURN reportCallocOverflow(uptr Count, uptr Size) {}

void NORETURN reportInvalidPosixMemalignAlignment(uptr Alignment) {}

void NORETURN reportPvallocOverflow(uptr Size) {}

void NORETURN reportInvalidAlignedAllocAlignment(uptr Alignment, uptr Size) {}

} // namespace scudo