[PATCH] D53556: [ExecutionEngine] Fix out-of-bounds access in the interpreter

Eugene Sharygin via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Sat Nov 3 02:24:56 PDT 2018


eush updated this revision to Diff 172489.
eush added a comment.

I grepped the code base, and it seems that the style in `alias.ll` is much
more common, in particular `intrinsics.ll` is the only test that runs lli with
input redirection, so I changed the test to match the style in `alias.ll`
instead.

I also renamed the test to better indicate what it is about.


Repository:
  rL LLVM

https://reviews.llvm.org/D53556

Files:
  lib/ExecutionEngine/Interpreter/ExternalFunctions.cpp
  test/ExecutionEngine/Interpreter/call-no-args.ll


Index: test/ExecutionEngine/Interpreter/call-no-args.ll
===================================================================
--- /dev/null
+++ test/ExecutionEngine/Interpreter/call-no-args.ll
@@ -0,0 +1,10 @@
+; RUN: %lli -force-interpreter %s
+
+declare void @exit(i32)
+declare i32 @rand()
+
+define i32 @main() {
+  %ret = call i32 @rand()
+  call void @exit(i32 0)
+  ret i32 %ret
+}
Index: lib/ExecutionEngine/Interpreter/ExternalFunctions.cpp
===================================================================
--- lib/ExecutionEngine/Interpreter/ExternalFunctions.cpp
+++ lib/ExecutionEngine/Interpreter/ExternalFunctions.cpp
@@ -227,7 +227,8 @@
   Type *RetTy = FTy->getReturnType();
   ffi_type *rtype = ffiTypeFor(RetTy);
 
-  if (ffi_prep_cif(&cif, FFI_DEFAULT_ABI, NumArgs, rtype, &args[0]) == FFI_OK) {
+  if (ffi_prep_cif(&cif, FFI_DEFAULT_ABI, NumArgs, rtype, args.data()) ==
+      FFI_OK) {
     SmallVector<uint8_t, 128> ret;
     if (RetTy->getTypeID() != Type::VoidTyID)
       ret.resize(TD.getTypeStoreSize(RetTy));


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D53556.172489.patch
Type: text/x-patch
Size: 1037 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20181103/35873690/attachment.bin>


More information about the llvm-commits mailing list