[llvm-commits] [llvm] r169783 - /llvm/trunk/utils/TableGen/DFAPacketizerEmitter.cpp

Anshuman Dasgupta adasgupt at codeaurora.org
Tue Dec 11 07:26:42 PST 2012


> Could you reproduce this under valgrind/asan/etc? A test case that
> would fail under such tools wouldn't be a bad thing to add.

I could not reproduce the invalid read in a test case. I'm still looking into it but I believe Carlos has a test that consistently fails. Once that's checked in, it'll cover this bug.

-Anshu



On 12/10/2012 5:07 PM, David Blaikie wrote:
> On Mon, Dec 10, 2012 at 2:45 PM, Anshuman Dasgupta
> <adasgupt at codeaurora.org> wrote:
>> Author: adasgupt
>> Date: Mon Dec 10 16:45:57 2012
>> New Revision: 169783
>>
>> URL: http://llvm.org/viewvc/llvm-project?rev=169783&view=rev
>> Log:
>> Fix PR14568: Avoid the DFA packetizer from making an invalid read
>> beyond array bounds.
>>
>> No test case since I cannot reproduce an ICE with this bug. According
>> to Carlos -- the bug reporter -- a segfault occurs only when LLVM is
>> compiled with a specific version of GCC.
> Could you reproduce this under valgrind/asan/etc? A test case that
> would fail under such tools wouldn't be a bad thing to add.
>
>> Modified:
>>      llvm/trunk/utils/TableGen/DFAPacketizerEmitter.cpp
>>
>> Modified: llvm/trunk/utils/TableGen/DFAPacketizerEmitter.cpp
>> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/utils/TableGen/DFAPacketizerEmitter.cpp?rev=169783&r1=169782&r2=169783&view=diff
>> ==============================================================================
>> --- llvm/trunk/utils/TableGen/DFAPacketizerEmitter.cpp (original)
>> +++ llvm/trunk/utils/TableGen/DFAPacketizerEmitter.cpp Mon Dec 10 16:45:57 2012
>> @@ -279,6 +279,7 @@
>>   //
>>   //
>>   void DFA::writeTableAndAPI(raw_ostream &OS, const std::string &TargetName) {
>> +  static const std::string SentinelEntry = "{-1, -1}";
>>     DFA::StateSet::iterator SI = states.begin();
>>     // This table provides a map to the beginning of the transitions for State s
>>     // in DFAStateInputTable.
>> @@ -305,12 +306,17 @@
>>       // If there are no valid transitions from this stage, we need a sentinel
>>       // transition.
>>       if (ValidTransitions == StateEntry[i]) {
>> -      OS << "{-1, -1},";
>> +      OS << SentinelEntry << ",";
>>         ++ValidTransitions;
>>       }
>>
>>       OS << "\n";
>>     }
>> +
>> +  // Print out a sentinel entry at the end of the StateInputTable. This is
>> +  // needed to iterate over StateInputTable in DFAPacketizer::ReadTable()
>> +  OS << SentinelEntry << "\n";
>> +
>>     OS << "};\n\n";
>>     OS << "const unsigned int " << TargetName << "DFAStateEntryTable[] = {\n";
>>
>> @@ -319,6 +325,9 @@
>>     for (unsigned i = 0; i < states.size(); ++i)
>>       OS << StateEntry[i] << ", ";
>>
>> +  // Print out the index to the sentinel entry in StateInputTable
>> +  OS << ValidTransitions << ", ";
>> +
>>     OS << "\n};\n";
>>     OS << "} // namespace\n";
>>
>>
>>
>> _______________________________________________
>> llvm-commits mailing list
>> llvm-commits at cs.uiuc.edu
>> http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits




More information about the llvm-commits mailing list