[all-commits] [llvm/llvm-project] dd0163: [analyzer] Fix crash in BasicValueFactory.cpp with...

vabridgers via All-commits all-commits at lists.llvm.org
Mon Oct 2 07:54:36 PDT 2023


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: dd01633c8160e54cc1bc379498cbade646375813
      https://github.com/llvm/llvm-project/commit/dd01633c8160e54cc1bc379498cbade646375813
  Author: vabridgers <58314289+vabridgers at users.noreply.github.com>
  Date:   2023-10-02 (Mon, 02 Oct 2023)

  Changed paths:
    M clang/docs/ReleaseNotes.rst
    M clang/lib/StaticAnalyzer/Core/BasicValueFactory.cpp
    A clang/test/Analysis/int128-nocrash.c

  Log Message:
  -----------
  [analyzer] Fix crash in BasicValueFactory.cpp with __int128_t integers (#67212)

This change avoids a crash in BasicValueFactory by checking the bit
width of an APSInt to avoid calling getZExtValue if greater than
64-bits. This was caught by our internal, randomized test generator.

Clang invocation
clang -cc1 -analyzer-checker=optin.portability.UnixAPI case.c

<src-root>/llvm/include/llvm/ADT/APInt.h:1488:
uint64_t llvm::APInt::getZExtValue() const: Assertion `getActiveBits()
<= 64
  && "Too many bits for uint64_t"' failed.
...

 #9 <address> llvm::APInt::getZExtValue() const
     <src-root>/llvm/include/llvm/ADT/APInt.h:1488:5
clang::BinaryOperatorKind, llvm::APSInt const&, llvm::APSInt const&)
<src-root>/clang/lib/StaticAnalyzer/Core/BasicValueFactory.cpp:307:37
     llvm::IntrusiveRefCntPtr<clang::ento::ProgramState const>,
clang::BinaryOperatorKind, clang::ento::NonLoc, clang::ento::NonLoc,
     clang::QualType)
<src-root>/clang/lib/StaticAnalyzer/Core/SimpleSValBuilder.cpp:531:31
     llvm::IntrusiveRefCntPtr<clang::ento::ProgramState const>,
     clang::BinaryOperatorKind, clang::ento::SVal, clang::ento::SVal,
     clang::QualType)
     <src-root>/clang/lib/StaticAnalyzer/Core/SValBuilder.cpp:532:26
...




More information about the All-commits mailing list