Author: Raphael Isemann Date: 2021-05-24T15:23:32+02:00 New Revision: 42a9c0c80c23fa0de3e3b00fef0dfa6d85e18e55
URL: https://github.com/llvm/llvm-project/commit/42a9c0c80c23fa0de3e3b00fef0dfa6d85e18e55 DIFF: https://github.com/llvm/llvm-project/commit/42a9c0c80c23fa0de3e3b00fef0dfa6d85e18e55.diff LOG: [lldb] Reland "Fix UB in half2float" to fix the ubsan bot. This relands part of the UB fix in 4b074b49be206306330076b9fa40632ef1960823. The original commit also added some additional tests that uncovered some other issues (see D102845). I landed all the passing tests in 48780527dd6820698f3537f5ebf76499030ee349 and this patch is now just fixing the UB in half2float. See D102846 for a proposed rewrite of the function. Original commit message: The added DumpDataExtractorTest uncovered that this is lshifting a negative integer which upsets ubsan and breaks the sanitizer bot. This patch just changes the variable we shift to be unsigned. Added: Modified: lldb/source/Core/DumpDataExtractor.cpp Removed: ################################################################################ diff --git a/lldb/source/Core/DumpDataExtractor.cpp b/lldb/source/Core/DumpDataExtractor.cpp index ec44e3481c1e5..34c9353c9feaa 100644 --- a/lldb/source/Core/DumpDataExtractor.cpp +++ b/lldb/source/Core/DumpDataExtractor.cpp @@ -52,7 +52,9 @@ static float half2float(uint16_t half) { float f; uint32_t u; } u; - int32_t v = (int16_t)half; + // Sign extend to 4 byte. + int32_t sign_extended = static_cast<int16_t>(half); + uint32_t v = static_cast<uint32_t>(sign_extended); if (0 == (v & 0x7c00)) { u.u = v & 0x80007FFFU; _______________________________________________ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits