[PATCH] D144565: dwp check overflow

Alexander Yermolovich via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Mon Mar 27 12:35:40 PDT 2023


ayermolo added a comment.

Don't really have a strong opinion, but maybe other reviewers do. Right now we have two types of checks;
pre condition check:
std::numeric_limits<uint32_t>::max() - InfoSectionOffset <

  C.getLength32()

and
post condition check:
OldOffset > TypesOffset

Should this be standardized to one or the other type of check?



================
Comment at: llvm/lib/DWP/DWP.cpp:234
     C.setOffset(TypesOffset);
+    uint32_t OldOffset = TypesOffset;
     TypesOffset += C.getLength();
----------------
Maybe a static_assert that sizeof(OldOffset) == sizeof(TypeOffset)?


================
Comment at: llvm/lib/DWP/DWP.cpp:688
       ContributionOffsets[Index] += CurEntry.Contributions[Index].getLength32();
+      if (ContributionOffsets[Index] < OldOffset) {
+        uint32_t SectionIndex = 0;
----------------
OldOffset > ContributionOffsets[Index]
Just to keep it consistent with other checks.


================
Comment at: llvm/test/tools/llvm-dwp/X86/overflow_debug_info.test:2
+RUN: llvm-mc --triple=x86_64-unknown-linux --filetype=obj --split-dwarf-file=debug_info.dwo -dwarf-version=5 %p/../Inputs/overflow/debug_info.s -o debug_info.o
+RUN: llvm-mc --triple=x86_64-unknown-linux --filetype=obj --split-dwarf-file=main.dwo -dwarf-version=5 %p/../Inputs/overflow/main.s -o main.o
+RUN: not llvm-dwp -e debug_info.o -e main.o -o overflow.dwp 2>&1 | FileCheck %s
----------------
steven.zhang wrote:
> How about the dwarf 4 ?
Actually looking at assembly those are DWARF4 tests.
example:
        .short	4                               # DWARF version number
	.byte	4                               # DW_AT_GNU_dwo_name
	.quad	-346972125991005518             # DW_AT_GNU_dwo_id


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D144565/new/

https://reviews.llvm.org/D144565



More information about the llvm-commits mailing list