<div dir="ltr"><br><div class="gmail_extra"><br><br><div class="gmail_quote">On Thu, May 23, 2013 at 10:58 AM, Kevin Enderby <span dir="ltr"><<a href="mailto:enderby@apple.com" target="_blank">enderby@apple.com</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Hi Eric,<br>
<br>
What was happening is the library call was being handed a bad triple and should have simply returned it could not create a disassembler by returning the value 0 indicating failure.  The code calling this ABI correctly handled the return value of 0.  So I was testing my code in darwin's otool(1) that it was handled the error case correctly but it was crashing instead.<br>

<br>
Without this code in the library:<br>
<br>
> if (!TheTarget)<br>
>  return 0;<br>
<br>
it was falling through and using the NULL value of TheTarget variable to be used and then crashing.<br>
<br>
In this "normal error path" I don't want an assert in at any time with any configuration.<br></blockquote><div><br></div><div style>Is there a missing test case, then?</div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">

<br>
Hope that explains what the fix was doing,<br>
Kev<br>
<div class="HOEnZb"><div class="h5"><br>
On May 23, 2013, at 10:46 AM, Eric Christopher <<a href="mailto:echristo@gmail.com">echristo@gmail.com</a>> wrote:<br>
<br>
> Hi Kevin,<br>
><br>
> I'm not sure I understand why removing the asserts is a good thing. I<br>
> can easily understand the:<br>
><br>
> if (!TheTarget)<br>
>  return 0;<br>
><br>
> part as that fixes a bug when used as a library, but you'll likely not<br>
> ship the library in asserts mode and the assert will help you find<br>
> bugs faster?<br>
><br>
> -eric<br>
><br>
><br>
> On Wed, May 22, 2013 at 5:32 PM, Kevin Enderby <<a href="mailto:enderby@apple.com">enderby@apple.com</a>> wrote:<br>
>> Author: enderby<br>
>> Date: Wed May 22 19:32:34 2013<br>
>> New Revision: 182542<br>
>><br>
>> URL: <a href="http://llvm.org/viewvc/llvm-project?rev=182542&view=rev" target="_blank">http://llvm.org/viewvc/llvm-project?rev=182542&view=rev</a><br>
>> Log:<br>
>> Missed removing one of the assert()'s from the LLVMCreateDisasmCPU() library<br>
>> API with my 176880 revision.  If a bad Triple is passed in it can also assert.<br>
>> In this case too it should just return 0 to indicate failure to create the<br>
>> disassembler.<br>
>><br>
>> rdar://13955214<br>
>><br>
>> Modified:<br>
>>    llvm/trunk/lib/MC/MCDisassembler/Disassembler.cpp<br>
>><br>
>> Modified: llvm/trunk/lib/MC/MCDisassembler/Disassembler.cpp<br>
>> URL: <a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/MC/MCDisassembler/Disassembler.cpp?rev=182542&r1=182541&r2=182542&view=diff" target="_blank">http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/MC/MCDisassembler/Disassembler.cpp?rev=182542&r1=182541&r2=182542&view=diff</a><br>

>> ==============================================================================<br>
>> --- llvm/trunk/lib/MC/MCDisassembler/Disassembler.cpp (original)<br>
>> +++ llvm/trunk/lib/MC/MCDisassembler/Disassembler.cpp Wed May 22 19:32:34 2013<br>
>> @@ -40,7 +40,8 @@ LLVMDisasmContextRef LLVMCreateDisasmCPU<br>
>>   // Get the target.<br>
>>   std::string Error;<br>
>>   const Target *TheTarget = TargetRegistry::lookupTarget(Triple, Error);<br>
>> -  assert(TheTarget && "Unable to create target!");<br>
>> +  if (!TheTarget)<br>
>> +    return 0;<br>
>><br>
>>   const MCRegisterInfo *MRI = TheTarget->createMCRegInfo(Triple);<br>
>>   if (!MRI)<br>
>><br>
>><br>
>> _______________________________________________<br>
>> llvm-commits mailing list<br>
>> <a href="mailto:llvm-commits@cs.uiuc.edu">llvm-commits@cs.uiuc.edu</a><br>
>> <a href="http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits" target="_blank">http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits</a><br>
<br>
_______________________________________________<br>
llvm-commits mailing list<br>
<a href="mailto:llvm-commits@cs.uiuc.edu">llvm-commits@cs.uiuc.edu</a><br>
<a href="http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits" target="_blank">http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits</a><br>
</div></div></blockquote></div><br></div></div>