Copyright | (c) Galois Inc 2018 |
---|---|
License | BSD3 |
Maintainer | Langston Barrett <[email protected]> |
Stability | provisional |
Safe Haskell | Safe-Inferred |
Language | Haskell2010 |
Lang.Crucible.LLVM.Errors.UndefinedBehavior
Contents
Description
This module is intended to be imported qualified.
This module serves as an ad-hoc reference for the sort of undefined behaviors that the Crucible LLVM memory model is aware of. The information contained here is used in * providing helpful error messages * configuring which safety checks to perform
Disabling checks for undefined behavior does not change the behavior of any memory operations. If it is used to enable the simulation of undefined behavior, the result is that any guarantees that Crucible provides about the code essentially have an additional hypothesis: that the LLVM compiler/hardware platform behave identically to Crucible's simulator when encountering such behavior.
Synopsis
- data PtrComparisonOperator
- data UndefinedBehavior (e :: CrucibleType -> Type) where
- FreeBadOffset :: 1 <= w => e (LLVMPointerType w) -> UndefinedBehavior e
- FreeUnallocated :: 1 <= w => e (LLVMPointerType w) -> UndefinedBehavior e
- DoubleFree :: 1 <= w => e (LLVMPointerType w) -> UndefinedBehavior e
- MemsetInvalidRegion :: (1 <= w, 1 <= v) => e (LLVMPointerType w) -> e (BVType 8) -> e (BVType v) -> UndefinedBehavior e
- ReadBadAlignment :: 1 <= w => e (LLVMPointerType w) -> Alignment -> UndefinedBehavior e
- WriteBadAlignment :: 1 <= w => e (LLVMPointerType w) -> Alignment -> UndefinedBehavior e
- PtrAddOffsetOutOfBounds :: 1 <= w => e (LLVMPointerType w) -> e (BVType w) -> UndefinedBehavior e
- CompareInvalidPointer :: 1 <= w => PtrComparisonOperator -> e (LLVMPointerType w) -> e (LLVMPointerType w) -> UndefinedBehavior e
- CompareDifferentAllocs :: 1 <= w => e (LLVMPointerType w) -> e (LLVMPointerType w) -> UndefinedBehavior e
- PtrSubDifferentAllocs :: 1 <= w => e (LLVMPointerType w) -> e (LLVMPointerType w) -> UndefinedBehavior e
- PointerIntCast :: 1 <= w => e (LLVMPointerType w) -> StorageType -> UndefinedBehavior e
- PointerUnsupportedOp :: 1 <= w => e (LLVMPointerType w) -> String -> UndefinedBehavior e
- PointerFloatCast :: 1 <= w => e (LLVMPointerType w) -> StorageType -> UndefinedBehavior e
- ComparePointerToBV :: 1 <= w => e (LLVMPointerType w) -> e (BVType w) -> UndefinedBehavior e
- UDivByZero :: 1 <= w => e (BVType w) -> e (BVType w) -> UndefinedBehavior e
- SDivByZero :: 1 <= w => e (BVType w) -> e (BVType w) -> UndefinedBehavior e
- URemByZero :: 1 <= w => e (BVType w) -> e (BVType w) -> UndefinedBehavior e
- SRemByZero :: 1 <= w => e (BVType w) -> e (BVType w) -> UndefinedBehavior e
- SDivOverflow :: 1 <= w => e (BVType w) -> e (BVType w) -> UndefinedBehavior e
- SRemOverflow :: 1 <= w => e (BVType w) -> e (BVType w) -> UndefinedBehavior e
- AbsIntMin :: 1 <= w => e (BVType w) -> UndefinedBehavior e
- PoisonValueCreated :: Poison e -> UndefinedBehavior e
- cite :: UndefinedBehavior e -> Doc ann
- details :: IsExpr (SymExpr sym) => UndefinedBehavior (RegValue' sym) -> [Doc ann]
- explain :: UndefinedBehavior e -> Doc ann
- ppDetails :: IsExpr (SymExpr sym) => UndefinedBehavior (RegValue' sym) -> Doc ann
- ppCitation :: UndefinedBehavior e -> [Doc ann]
- pp :: (UndefinedBehavior e -> [Doc ann]) -> UndefinedBehavior e -> Doc ann
- concUB :: forall sym. IsExprBuilder sym => sym -> (forall tp. SymExpr sym tp -> IO (GroundValue tp)) -> UndefinedBehavior (RegValue' sym) -> IO (UndefinedBehavior (RegValue' sym))
Undefined Behavior
data PtrComparisonOperator Source #
The various comparison operators you can use on pointers
Instances
data UndefinedBehavior (e :: CrucibleType -> Type) where Source #
This type is parameterized on a higher-kinded term constructor so that it
can be instantiated for expressions at translation time (i.e. the Expr
in
LLVMGenerator
), or for expressions at runtime (SymExpr
).
See cite
and explain
for what each constructor means at the C/LLVM level.
The commented-out constructors correspond to behaviors that don't have explicit checks yet (but probably should!).
Constructors
FreeBadOffset :: 1 <= w => e (LLVMPointerType w) -> UndefinedBehavior e | |
FreeUnallocated :: 1 <= w => e (LLVMPointerType w) -> UndefinedBehavior e | |
DoubleFree :: 1 <= w => e (LLVMPointerType w) -> UndefinedBehavior e | |
MemsetInvalidRegion :: (1 <= w, 1 <= v) => e (LLVMPointerType w) -> e (BVType 8) -> e (BVType v) -> UndefinedBehavior e | Arguments: Destination pointer, fill byte, length |
ReadBadAlignment :: 1 <= w => e (LLVMPointerType w) -> Alignment -> UndefinedBehavior e | Arguments: Read destination, alignment |
WriteBadAlignment :: 1 <= w => e (LLVMPointerType w) -> Alignment -> UndefinedBehavior e | Arguments: Write destination, alignment |
PtrAddOffsetOutOfBounds :: 1 <= w => e (LLVMPointerType w) -> e (BVType w) -> UndefinedBehavior e | |
CompareInvalidPointer :: 1 <= w => PtrComparisonOperator -> e (LLVMPointerType w) -> e (LLVMPointerType w) -> UndefinedBehavior e | Arguments: kind of comparison, the invalid pointer, the other pointer |
CompareDifferentAllocs :: 1 <= w => e (LLVMPointerType w) -> e (LLVMPointerType w) -> UndefinedBehavior e | "In all other cases, the behavior is undefined"
TODO: |
PtrSubDifferentAllocs :: 1 <= w => e (LLVMPointerType w) -> e (LLVMPointerType w) -> UndefinedBehavior e | "When two pointers are subtracted, both shall point to elements of the same array object" |
PointerIntCast :: 1 <= w => e (LLVMPointerType w) -> StorageType -> UndefinedBehavior e | Pointer cast to an integer type other than pointer width integers |
PointerUnsupportedOp :: 1 <= w => e (LLVMPointerType w) -> String -> UndefinedBehavior e | Pointer used in an unsupported arithmetic or bitvector operation |
PointerFloatCast :: 1 <= w => e (LLVMPointerType w) -> StorageType -> UndefinedBehavior e | Pointer cast to a floating-point type |
ComparePointerToBV :: 1 <= w => e (LLVMPointerType w) -> e (BVType w) -> UndefinedBehavior e | "One of the following shall hold: [...] one operand is a pointer and the other is a null pointer constant." |
UDivByZero :: 1 <= w => e (BVType w) -> e (BVType w) -> UndefinedBehavior e |
|
SDivByZero :: 1 <= w => e (BVType w) -> e (BVType w) -> UndefinedBehavior e | |
URemByZero :: 1 <= w => e (BVType w) -> e (BVType w) -> UndefinedBehavior e | |
SRemByZero :: 1 <= w => e (BVType w) -> e (BVType w) -> UndefinedBehavior e | |
SDivOverflow :: 1 <= w => e (BVType w) -> e (BVType w) -> UndefinedBehavior e | |
SRemOverflow :: 1 <= w => e (BVType w) -> e (BVType w) -> UndefinedBehavior e | |
AbsIntMin :: 1 <= w => e (BVType w) -> UndefinedBehavior e | |
PoisonValueCreated :: Poison e -> UndefinedBehavior e |
Instances
cite :: UndefinedBehavior e -> Doc ann Source #
Which section(s) of the document prohibit this behavior?
details :: IsExpr (SymExpr sym) => UndefinedBehavior (RegValue' sym) -> [Doc ann] Source #
Pretty-print the additional information held by the constructors (for symbolic expressions)
explain :: UndefinedBehavior e -> Doc ann Source #
What happened, and why is it a problem?
This is a generic explanation that doesn't use the included data.
ppDetails :: IsExpr (SymExpr sym) => UndefinedBehavior (RegValue' sym) -> Doc ann Source #
Pretty-printer for symbolic backends
ppCitation :: UndefinedBehavior e -> [Doc ann] Source #
Arguments
:: (UndefinedBehavior e -> [Doc ann]) | Printer for constructor data |
-> UndefinedBehavior e | |
-> Doc ann |
concUB :: forall sym. IsExprBuilder sym => sym -> (forall tp. SymExpr sym tp -> IO (GroundValue tp)) -> UndefinedBehavior (RegValue' sym) -> IO (UndefinedBehavior (RegValue' sym)) Source #