From 27ca64f3d3887ee500c0cab672f6aa9fc87f9ff7 Mon Sep 17 00:00:00 2001 From: Filipe Cabecinhas Date: Tue, 19 May 2015 18:18:10 +0000 Subject: [PATCH] Change a reachable unreachable to a fatal error. Summary: Also tagged a FIXME comment, and added information about why it breaks. Bug found using AFL fuzz. Reviewers: rafael, craig.topper Subscribers: llvm-commits Differential Revision: http://reviews.llvm.org/D9729 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@237709 91177308-0d34-0410-b5e6-96231b3b80d8 --- include/llvm/Support/StreamingMemoryObject.h | 11 ++++++----- .../Inputs/invalid-fixme-streaming-blob.bc | Bin 0 -> 371 bytes test/Bitcode/invalid.test | 5 +++++ 3 files changed, 11 insertions(+), 5 deletions(-) create mode 100644 test/Bitcode/Inputs/invalid-fixme-streaming-blob.bc diff --git a/include/llvm/Support/StreamingMemoryObject.h b/include/llvm/Support/StreamingMemoryObject.h index fb63da7dbcc..9d1d607005f 100644 --- a/include/llvm/Support/StreamingMemoryObject.h +++ b/include/llvm/Support/StreamingMemoryObject.h @@ -29,11 +29,12 @@ public: uint64_t readBytes(uint8_t *Buf, uint64_t Size, uint64_t Address) const override; const uint8_t *getPointer(uint64_t address, uint64_t size) const override { - // This could be fixed by ensuring the bytes are fetched and making a copy, - // requiring that the bitcode size be known, or otherwise ensuring that - // the memory doesn't go away/get reallocated, but it's - // not currently necessary. Users that need the pointer don't stream. - llvm_unreachable("getPointer in streaming memory objects not allowed"); + // FIXME: This could be fixed by ensuring the bytes are fetched and + // making a copy, requiring that the bitcode size be known, or + // otherwise ensuring that the memory doesn't go away/get reallocated, + // but it's not currently necessary. Users that need the pointer (any + // that need Blobs) don't stream. + report_fatal_error("getPointer in streaming memory objects not allowed"); return nullptr; } bool isValidAddress(uint64_t address) const override; diff --git a/test/Bitcode/Inputs/invalid-fixme-streaming-blob.bc b/test/Bitcode/Inputs/invalid-fixme-streaming-blob.bc new file mode 100644 index 0000000000000000000000000000000000000000..7e32f8b0774f9004171ebd4e9d435a2821399ee0 GIT binary patch literal 371 zcmZ>AK5$Qwhk+rFfq{X$Nr8b0NDBcmd!zD1#}h1`Yyw7>lNeigR9QJBWCyV@D%zAD)@+Q2mo50r~nQV9$}V)8HX5p)C7PAgA50P u&4SG!;t}`HoW&j>a8@KyO(ABhsDPm2)iei}mK0`?Vh|8vU;qGgdQl<( literal 0 HcmV?d00001 diff --git a/test/Bitcode/invalid.test b/test/Bitcode/invalid.test index 7a2dbdcc1b3..f609d043df4 100644 --- a/test/Bitcode/invalid.test +++ b/test/Bitcode/invalid.test @@ -157,3 +157,8 @@ RUN: not llvm-dis -disable-output %p/Inputs/invalid-function-argument-type.bc 2> RUN: FileCheck --check-prefix=INVALID-ARGUMENT-TYPE %s INVALID-ARGUMENT-TYPE: Invalid function argument type + +RUN: not llvm-dis -disable-output %p/Inputs/invalid-fixme-streaming-blob.bc 2>&1 | \ +RUN: FileCheck --check-prefix=STREAMING-BLOB %s + +STREAMING-BLOB: getPointer in streaming memory objects not allowed