[llvm] r252192 - Reapply r250906 with many suggested updates from Rafael Espindola.

Kevin Enderby via llvm-commits llvm-commits at lists.llvm.org
Fri Nov 6 10:15:36 PST 2015


Hello Pasi,

When I ran a make check-all I did not see any crashes.  Can you point me to the test case for the lld-link crash?  Then I can fix this. Top of tree for my just now with a make check-all also is clean and the 4 lld build bots appear to be green at this time.

The constructor for Archive::Child::Child() only allows nullptr as EC argument when Parent and Start are also nullptr.  Which is needed for the default constructor of child_iterator().  At one point we needed this as I think ArchiveWriter was using this.  As it would have seemed to be more correct to pass EC as a reference but I didn’t see how to make that work with a default constructor for child_iterator().

In the original diff I had this as an assert (see http://reviews.llvm.org/D13989 <http://reviews.llvm.org/D13989> ):

    if (MemberSize.getError()) {
      assert (EC && "Error must be caught");
      *EC = MemberSize.getError();
      return;
    }

But Rafael said in the review: "You can write this as”:

     if ((EC = MemberSize.getError())
      return;

The fix to a crash lld-link is likely simply passing a proper value for EC and testing for the error.  And I suspect this is what Rafael would like to see as he doesn’t want the code to eat these errors in any place.

Happy to make this change if you can point me to the crash or the test case.

Kev

> On Nov 6, 2015, at 12:23 AM, Pasi Parviainen <pasi.parviainen at iki.fi> wrote:
> 
>> @@ -86,7 +86,8 @@ Archive::Child::Child(const Archive *Par
>>                        uint16_t StartOfFile)
>>      : Parent(Parent), Data(Data), StartOfFile(StartOfFile) {}
>> 
>> -Archive::Child::Child(const Archive *Parent, const char *Start)
>> +Archive::Child::Child(const Archive *Parent, const char *Start,
>> +                      std::error_code *EC)
>>      : Parent(Parent) {
>>    if (!Start)
>>      return;
>> @@ -94,7 +95,10 @@ Archive::Child::Child(const Archive *Par
>>    uint64_t Size = sizeof(ArchiveMemberHeader);
>>    Data = StringRef(Start, Size);
>>    if (!isThinMember()) {
>> -    Size += getRawSize();
>> +    ErrorOr<uint64_t> MemberSize = getRawSize();
>> +    if ((*EC = MemberSize.getError()))
>> +      return;
> 
> lld-link is crashing here since matching changes to lld in r252193. Crash is caused by passing nullptr as EC argument. If nullptr is valid value for EC then this check should be more like:
> 
>    if (!MemberSize) {
>      if (EC)
>        *EC = MemberSize.getError();
>      return;
>    }
> 
> Pasi

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20151106/8528e1ac/attachment.html>


More information about the llvm-commits mailing list