about summary refs log tree commit diff homepage
path: root/lib/Core/Executor.h
diff options
context:
space:
mode:
authorMartin Nowack <martin.nowack@gmail.com>2018-05-05 00:04:13 +0100
committerCristian Cadar <c.cadar@imperial.ac.uk>2018-05-05 10:35:28 +0100
commitab03c1cdce90660dcb75d000ebda817ae589aaec (patch)
tree7d884b530e8940bc0de8d3227ac944d3798282bb /lib/Core/Executor.h
parent4211cea27f1903f68c2b32267eb34cb95c24b9f3 (diff)
downloadklee-ab03c1cdce90660dcb75d000ebda817ae589aaec.tar.gz
Fix handling of errno if external functions are invoked
If an external function in KLEE is invoked, it might update errno.
Previously, the errno specific variable in a state was only updated
if it was part of the executed instructions.
That opened up a timeframe that increased the likelihood of errno being
overwritten by another method call.

This patch fixes two issues:
* the errno of the KLEE process state is updated before the external
function call allowing to detect changes to it later on
* after the external call, the memory object of errno is directly
updated
with its new value, reducing the likelihood to be overwritten by
another
call

Additional features:
* Add support for `errno()` for Darwin as well.
* Simplified errno handling in POSIX layer
Diffstat (limited to 'lib/Core/Executor.h')
-rw-r--r--lib/Core/Executor.h3
1 files changed, 3 insertions, 0 deletions
diff --git a/lib/Core/Executor.h b/lib/Core/Executor.h
index 71b1f5f7..1bc91be0 100644
--- a/lib/Core/Executor.h
+++ b/lib/Core/Executor.h
@@ -525,6 +525,9 @@ public:
 
   Expr::Width getWidthForLLVMType(llvm::Type *type) const;
   size_t getAllocationAlignment(const llvm::Value *allocSite) const;
+
+  /// Returns the errno location in memory of the state
+  int *getErrnoLocation(const ExecutionState &state) const;
 };
   
 } // End klee namespace