Skip to content

Commit

Permalink
Merge detect_clang_bug96267
Browse files Browse the repository at this point in the history
  • Loading branch information
luke-jr committed Jun 21, 2024
2 parents ea949da + 52ed096 commit b1fd3a6
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 0 deletions.
18 changes: 18 additions & 0 deletions src/kernel/checks.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,30 @@

namespace kernel {

bool Clang_IndVarSimplify_Bug_SanityCheck() {
// See https://github.com/llvm/llvm-project/issues/96267
const char s[] = {0, 0x75};
signed int last = 0xff;
for (const char *it = s; it < &s[2]; ++it) {
if (*it <= 0x4e) {
} else if (*it == 0x75 && last <= 0x4e) {
return true;
}
last = *it;
}
return false;
}

util::Result<void> SanityChecks(const Context&)
{
if (!dbwrapper_SanityCheck()) {
return util::Error{Untranslated("Database sanity check failure. Aborting.")};
}

if (!Clang_IndVarSimplify_Bug_SanityCheck()) {
return util::Error{Untranslated("Compiler optimization sanity check failure. Aborting.")};
}

if (!ECC_InitSanityCheck()) {
return util::Error{Untranslated("Elliptic curve cryptography sanity check failure. Aborting.")};
}
Expand Down
2 changes: 2 additions & 0 deletions src/kernel/checks.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ namespace kernel {

struct Context;

[[nodiscard]] bool Clang_IndVarSimplify_Bug_SanityCheck();

/**
* Ensure a usable environment with all necessary library support.
*/
Expand Down
2 changes: 2 additions & 0 deletions src/test/sanity_tests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
// file COPYING or http://www.opensource.org/licenses/mit-license.php.

#include <dbwrapper.h>
#include <kernel/checks.h>
#include <key.h>
#include <test/util/setup_common.h>
#include <util/time.h>
Expand All @@ -14,6 +15,7 @@ BOOST_FIXTURE_TEST_SUITE(sanity_tests, BasicTestingSetup)
BOOST_AUTO_TEST_CASE(basic_sanity)
{
BOOST_CHECK_MESSAGE(dbwrapper_SanityCheck() == true, "dbwrapper sanity test");
BOOST_CHECK_MESSAGE(kernel::Clang_IndVarSimplify_Bug_SanityCheck() == true, "Clang IndVarSimplify bug sanity test");
BOOST_CHECK_MESSAGE(ECC_InitSanityCheck() == true, "secp256k1 sanity test");
BOOST_CHECK_MESSAGE(ChronoSanityCheck() == true, "chrono epoch test");
}
Expand Down

0 comments on commit b1fd3a6

Please sign in to comment.