[llvm] r232215 - Turn assertion into bitcode reading error

David Blaikie dblaikie at gmail.com
Mon Mar 16 15:11:27 PDT 2015


Test cases added in 232420, 232424, 232427.

I just wrote small examples and modified the writer temporarily to generate
the appropriately broken bitcode.

On Sat, Mar 14, 2015 at 11:22 AM, Filipe Cabecinhas <filcab at gmail.com>
wrote:

> test/BitCode/invalid.test with inputs from test/BitCode/Inputs/invalid-*.bc
>
> Constructing them is hard, though. I haven't automated anything, I just go
> and hexedit the smallest tests I can find :-(
>
> Good luck!
>
>
> On Saturday, March 14, 2015, David Blaikie <dblaikie at gmail.com> wrote:
>
>> Any examples of existing tests for invalid bitcode & how to construct
>> such input files?
>> On Mar 14, 2015 6:02 AM, "Rafael EspĂ­ndola" <rafael.espindola at gmail.com>
>> wrote:
>>
>>> Filipe has been adding tests for the error handling. The old testing
>>> situation was pretty bad, so if you could create a broken bitcode file to
>>> test this it would be awesome.
>>> On Mar 13, 2015 5:13 PM, "David Blaikie" <dblaikie at gmail.com> wrote:
>>>
>>>> Author: dblaikie
>>>> Date: Fri Mar 13 16:03:34 2015
>>>> New Revision: 232215
>>>>
>>>> URL: http://llvm.org/viewvc/llvm-project?rev=232215&view=rev
>>>> Log:
>>>> Turn assertion into bitcode reading error
>>>>
>>>> I don't think we test invalid bitcode records in any detail, so no test
>>>> here - just a change for consistency with existing error checks in
>>>> surrounding code.
>>>>
>>>> Modified:
>>>>     llvm/trunk/lib/Bitcode/Reader/BitcodeReader.cpp
>>>>
>>>> Modified: llvm/trunk/lib/Bitcode/Reader/BitcodeReader.cpp
>>>> URL:
>>>> http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Bitcode/Reader/BitcodeReader.cpp?rev=232215&r1=232214&r2=232215&view=diff
>>>>
>>>> ==============================================================================
>>>> --- llvm/trunk/lib/Bitcode/Reader/BitcodeReader.cpp (original)
>>>> +++ llvm/trunk/lib/Bitcode/Reader/BitcodeReader.cpp Fri Mar 13 16:03:34
>>>> 2015
>>>> @@ -3126,8 +3126,8 @@ std::error_code BitcodeReader::ParseFunc
>>>>        }
>>>>
>>>>        I = GetElementPtrInst::Create(BasePtr, GEPIdx);
>>>> -      (void)Ty;
>>>> -      assert(!Ty || Ty ==
>>>> cast<GetElementPtrInst>(I)->getSourceElementType());
>>>> +      if (Ty && Ty !=
>>>> cast<GetElementPtrInst>(I)->getSourceElementType())
>>>> +        return Error("Invalid record");
>>>>        InstructionList.push_back(I);
>>>>        if (InBounds)
>>>>          cast<GetElementPtrInst>(I)->setIsInBounds(true);
>>>>
>>>>
>>>> _______________________________________________
>>>> llvm-commits mailing list
>>>> llvm-commits at cs.uiuc.edu
>>>> http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits
>>>>
>>>
>
> --
>   F
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20150316/8e72107e/attachment.html>


More information about the llvm-commits mailing list