Skip to content

[libc] Use best-fit binary trie to make malloc logarithmic #106259

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 12 commits into from
Nov 20, 2024

Conversation

mysterymath
Copy link
Contributor

@mysterymath mysterymath commented Aug 27, 2024

This reworks the free store implementation in libc's malloc to use a dlmalloc-style binary trie of circularly linked FIFO free lists. This data structure can be maintained in logarithmic time, but it still permits a relatively small implementation compared to other logarithmic-time ordered maps.

The implementation doesn't do the various bitwise tricks or optimizations used in actual dlmalloc; it instead optimizes for (relative) readability and minimum code size. Specific optimization can be added as necessary given future profiling.

Copy link

github-actions bot commented Aug 27, 2024

✅ With the latest revision this PR passed the C/C++ code formatter.

@mysterymath mysterymath force-pushed the libc-malloc-best branch 6 times, most recently from 3cc6937 to 957140c Compare September 23, 2024 18:35
@mysterymath mysterymath changed the title [WIP][libc] Use best-fit binary trie to make malloc logarithmic [libc] Use best-fit binary trie to make malloc logarithmic Sep 27, 2024
@mysterymath mysterymath marked this pull request as ready for review September 27, 2024 23:55
@llvmbot llvmbot added the libc label Sep 27, 2024
@llvmbot
Copy link
Member

llvmbot commented Sep 27, 2024

@llvm/pr-subscribers-libc

Author: Daniel Thornburgh (mysterymath)

Changes

This reworks the free store implementation in libc's malloc to use a dlmalloc-style binary trie of circularly linked FIFO free lists. This data structure can be maintained in logarithmic time, but it still permits a relatively small implementation compared to other logarithmic-time ordered maps.

The implementation doesn't do the various bitwise tricks or optimizations used in actual dlmalloc; it instead optimizes for (relative) readability and minimum code size. Specific optimization can be added as necessary given future profiling.


Patch is 51.49 KiB, truncated to 20.00 KiB below, full version: https://github.com/llvm/llvm-project/pull/106259.diff

13 Files Affected:

  • (modified) libc/config/linux/x86_64/entrypoints.txt (+1)
  • (modified) libc/src/__support/block.h (+18-2)
  • (modified) libc/src/__support/freelist.h (+77-169)
  • (modified) libc/src/__support/freelist_heap.h (+57-80)
  • (added) libc/src/__support/freestore.h (+108)
  • (added) libc/src/__support/freetrie.h (+253)
  • (modified) libc/src/stdlib/freelist_malloc.cpp (+2-2)
  • (modified) libc/test/src/__support/CMakeLists.txt (+3)
  • (modified) libc/test/src/__support/freelist_heap_test.cpp (+10-10)
  • (modified) libc/test/src/__support/freelist_malloc_test.cpp (+1-1)
  • (modified) libc/test/src/__support/freelist_test.cpp (+28-144)
  • (added) libc/test/src/__support/freestore_test.cpp (+98)
  • (added) libc/test/src/__support/freetrie_test.cpp (+124)
diff --git a/libc/config/linux/x86_64/entrypoints.txt b/libc/config/linux/x86_64/entrypoints.txt
index dd658af3bfb674..42d6c5d85a7997 100644
--- a/libc/config/linux/x86_64/entrypoints.txt
+++ b/libc/config/linux/x86_64/entrypoints.txt
@@ -202,6 +202,7 @@ set(TARGET_LIBC_ENTRYPOINTS
     libc.src.stdlib.aligned_alloc
     libc.src.stdlib.calloc
     libc.src.stdlib.free
+    libc.src.stdlib.freelist_malloc
     libc.src.stdlib.malloc
     libc.src.stdlib.realloc
 
diff --git a/libc/src/__support/block.h b/libc/src/__support/block.h
index 96021b99587c87..e1f6726b27f08e 100644
--- a/libc/src/__support/block.h
+++ b/libc/src/__support/block.h
@@ -174,16 +174,32 @@ class Block {
     return inner_size - sizeof(prev_) + BLOCK_OVERHEAD;
   }
 
-  /// @returns The number of usable bytes inside the block.
+  /// @returns The number of usable bytes inside the block were it to be
+  /// allocated.
   size_t inner_size() const {
     if (!next())
       return 0;
     return inner_size(outer_size());
   }
 
+  /// @returns The number of usable bytes inside a block with the given outer
+  /// size were it to be allocated.
   static size_t inner_size(size_t outer_size) {
     // The usable region includes the prev_ field of the next block.
-    return outer_size - BLOCK_OVERHEAD + sizeof(prev_);
+    return inner_size_free(outer_size) + sizeof(prev_);
+  }
+
+  /// @returns The number of usable bytes inside the block if it remains free.
+  size_t inner_size_free() const {
+    if (!next())
+      return 0;
+    return inner_size_free(outer_size());
+  }
+
+  /// @returns The number of usable bytes inside a block with the given outer
+  /// size if it remains free.
+  static size_t inner_size_free(size_t outer_size) {
+    return outer_size - BLOCK_OVERHEAD;
   }
 
   /// @returns A pointer to the usable space inside this block.
diff --git a/libc/src/__support/freelist.h b/libc/src/__support/freelist.h
index a54cf953fe7ab6..0525f0f62b9229 100644
--- a/libc/src/__support/freelist.h
+++ b/libc/src/__support/freelist.h
@@ -1,4 +1,4 @@
-//===-- Interface for freelist_malloc -------------------------------------===//
+//===-- Interface for freelist --------------------------------------------===//
 //
 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
 // See https://llvm.org/LICENSE.txt for license information.
@@ -9,199 +9,107 @@
 #ifndef LLVM_LIBC_SRC___SUPPORT_FREELIST_H
 #define LLVM_LIBC_SRC___SUPPORT_FREELIST_H
 
-#include "src/__support/CPP/array.h"
-#include "src/__support/CPP/cstddef.h"
-#include "src/__support/CPP/new.h"
-#include "src/__support/CPP/span.h"
-#include "src/__support/fixedvector.h"
-#include "src/__support/macros/config.h"
+#include "block.h"
 
 namespace LIBC_NAMESPACE_DECL {
 
-using cpp::span;
-
-/// Basic [freelist](https://en.wikipedia.org/wiki/Free_list) implementation
-/// for an allocator. This implementation buckets by chunk size, with a list
-/// of user-provided buckets. Each bucket is a linked list of storage chunks.
-/// Because this freelist uses the added chunks themselves as list nodes, there
-/// is a lower bound of `sizeof(FreeList.FreeListNode)` bytes for chunks which
-/// can be added to this freelist. There is also an implicit bucket for
-/// "everything else", for chunks which do not fit into a bucket.
-///
-/// Each added chunk will be added to the smallest bucket under which it fits.
-/// If it does not fit into any user-provided bucket, it will be added to the
-/// default bucket.
-///
-/// As an example, assume that the `FreeList` is configured with buckets of
-/// sizes {64, 128, 256, and 512} bytes. The internal state may look like the
-/// following:
-///
-/// @code{.unparsed}
-/// bucket[0] (64B) --> chunk[12B] --> chunk[42B] --> chunk[64B] --> NULL
-/// bucket[1] (128B) --> chunk[65B] --> chunk[72B] --> NULL
-/// bucket[2] (256B) --> NULL
-/// bucket[3] (512B) --> chunk[312B] --> chunk[512B] --> chunk[416B] --> NULL
-/// bucket[4] (implicit) --> chunk[1024B] --> chunk[513B] --> NULL
-/// @endcode
+/// A circularly-linked FIFO list storing free Blocks. All Blocks on a list
+/// are the same size.
 ///
-/// Note that added chunks should be aligned to a 4-byte boundary.
-template <size_t NUM_BUCKETS = 6> class FreeList {
+/// Allocating free blocks in FIFO order maximizes the amount of time before a
+/// free block is reused. This in turn maximizes the number of opportunities for
+/// it to be coalesced with an adjacent block, which tends to reduce heap
+/// fragmentation.
+class FreeList {
 public:
-  // Remove copy/move ctors
-  FreeList(const FreeList &other) = delete;
-  FreeList(FreeList &&other) = delete;
-  FreeList &operator=(const FreeList &other) = delete;
-  FreeList &operator=(FreeList &&other) = delete;
-
-  /// Adds a chunk to this freelist.
-  bool add_chunk(cpp::span<cpp::byte> chunk);
-
-  /// Finds an eligible chunk for an allocation of size `size`.
-  ///
-  /// @note This returns the first allocation possible within a given bucket;
-  /// It does not currently optimize for finding the smallest chunk.
-  ///
-  /// @returns
-  /// * On success - A span representing the chunk.
-  /// * On failure (e.g. there were no chunks available for that allocation) -
-  ///   A span with a size of 0.
-  cpp::span<cpp::byte> find_chunk(size_t size) const;
-
-  template <typename Cond> cpp::span<cpp::byte> find_chunk_if(Cond op) const;
-
-  /// Removes a chunk from this freelist.
-  bool remove_chunk(cpp::span<cpp::byte> chunk);
-
-  /// For a given size, find which index into chunks_ the node should be written
-  /// to.
-  constexpr size_t find_chunk_ptr_for_size(size_t size, bool non_null) const;
-
-  struct FreeListNode {
-    FreeListNode *next;
-    size_t size;
-  };
-
-  constexpr void set_freelist_node(FreeListNode &node,
-                                   cpp::span<cpp::byte> chunk);
-
-  constexpr explicit FreeList(const cpp::array<size_t, NUM_BUCKETS> &sizes)
-      : chunks_(NUM_BUCKETS + 1, 0), sizes_(sizes.begin(), sizes.end()) {}
-
-private:
-  FixedVector<FreeList::FreeListNode *, NUM_BUCKETS + 1> chunks_;
-  FixedVector<size_t, NUM_BUCKETS> sizes_;
-};
-
-template <size_t NUM_BUCKETS>
-constexpr void FreeList<NUM_BUCKETS>::set_freelist_node(FreeListNode &node,
-                                                        span<cpp::byte> chunk) {
-  // Add it to the correct list.
-  size_t chunk_ptr = find_chunk_ptr_for_size(chunk.size(), false);
-  node.size = chunk.size();
-  node.next = chunks_[chunk_ptr];
-  chunks_[chunk_ptr] = &node;
-}
+  class Node {
+  public:
+    /// @returns The block containing this node.
+    Block<> *block() const {
+      return const_cast<Block<> *>(Block<>::from_usable_space(this));
+    }
 
-template <size_t NUM_BUCKETS>
-bool FreeList<NUM_BUCKETS>::add_chunk(span<cpp::byte> chunk) {
-  // Check that the size is enough to actually store what we need
-  if (chunk.size() < sizeof(FreeListNode))
-    return false;
+    /// @returns The inner size of blocks in the list containing this node.
+    size_t size() const { return block()->inner_size(); }
 
-  FreeListNode *node = ::new (chunk.data()) FreeListNode;
-  set_freelist_node(*node, chunk);
+  private:
+    // Circularly linked pointers to adjacent nodes.
+    Node *prev;
+    Node *next;
+    friend class FreeList;
+  };
 
-  return true;
-}
+  constexpr FreeList() : FreeList(nullptr) {}
+  constexpr FreeList(Node *begin) : begin_(begin) {}
 
-template <size_t NUM_BUCKETS>
-template <typename Cond>
-span<cpp::byte> FreeList<NUM_BUCKETS>::find_chunk_if(Cond op) const {
-  for (FreeListNode *node : chunks_) {
-    while (node != nullptr) {
-      span<cpp::byte> chunk(reinterpret_cast<cpp::byte *>(node), node->size);
-      if (op(chunk))
-        return chunk;
+  bool empty() const { return !begin_; }
 
-      node = node->next;
-    }
+  /// @returns The inner size of blocks in the list.
+  size_t size() const {
+    LIBC_ASSERT(begin_ && "empty lists have no size");
+    return begin_->size();
   }
 
-  return {};
-}
+  /// @returns The first node in the list.
+  Node *begin() { return begin_; }
 
-template <size_t NUM_BUCKETS>
-span<cpp::byte> FreeList<NUM_BUCKETS>::find_chunk(size_t size) const {
-  if (size == 0)
-    return span<cpp::byte>();
+  /// @returns The first block in the list.
+  Block<> *front() { return begin_->block(); }
 
-  size_t chunk_ptr = find_chunk_ptr_for_size(size, true);
+  /// Push a block to the back of the list.
+  /// The block must be large enough to contain a node.
+  void push(Block<> *block);
 
-  // Check that there's data. This catches the case where we run off the
-  // end of the array
-  if (chunks_[chunk_ptr] == nullptr)
-    return span<cpp::byte>();
+  /// Push an already-constructed node to the back of the list.
+  /// This allows pushing derived node types with additional data.
+  void push(Node *node);
 
-  // Now iterate up the buckets, walking each list to find a good candidate
-  for (size_t i = chunk_ptr; i < chunks_.size(); i++) {
-    FreeListNode *node = chunks_[static_cast<unsigned short>(i)];
+  /// Pop the first node from the list.
+  void pop();
 
-    while (node != nullptr) {
-      if (node->size >= size)
-        return span<cpp::byte>(reinterpret_cast<cpp::byte *>(node), node->size);
+  /// Remove an arbitrary node from the list.
+  void remove(Node *node);
 
-      node = node->next;
-    }
-  }
+private:
+  Node *begin_;
+};
 
-  // If we get here, we've checked every block in every bucket. There's
-  // nothing that can support this allocation.
-  return span<cpp::byte>();
+LIBC_INLINE void FreeList::push(Block<> *block) {
+  LIBC_ASSERT(!block->used() && "only free blocks can be placed on free lists");
+  LIBC_ASSERT(block->inner_size_free() >= sizeof(FreeList) &&
+              "block too small to accomodate free list node");
+  push(new (block->usable_space()) Node);
 }
 
-template <size_t NUM_BUCKETS>
-bool FreeList<NUM_BUCKETS>::remove_chunk(span<cpp::byte> chunk) {
-  size_t chunk_ptr = find_chunk_ptr_for_size(chunk.size(), true);
-
-  // Check head first.
-  if (chunks_[chunk_ptr] == nullptr)
-    return false;
-
-  FreeListNode *node = chunks_[chunk_ptr];
-  if (reinterpret_cast<cpp::byte *>(node) == chunk.data()) {
-    chunks_[chunk_ptr] = node->next;
-    return true;
+LIBC_INLINE void FreeList::push(Node *node) {
+  if (begin_) {
+    LIBC_ASSERT(Block<>::from_usable_space(node)->outer_size() ==
+                    begin_->block()->outer_size() &&
+                "freelist entries must have the same size");
+    // Since the list is circular, insert the node immediately before begin_.
+    node->prev = begin_->prev;
+    node->next = begin_;
+    begin_->prev->next = node;
+    begin_->prev = node;
+  } else {
+    begin_ = node->prev = node->next = node;
   }
-
-  // No? Walk the nodes.
-  node = chunks_[chunk_ptr];
-
-  while (node->next != nullptr) {
-    if (reinterpret_cast<cpp::byte *>(node->next) == chunk.data()) {
-      // Found it, remove this node out of the chain
-      node->next = node->next->next;
-      return true;
-    }
-
-    node = node->next;
-  }
-
-  return false;
 }
 
-template <size_t NUM_BUCKETS>
-constexpr size_t
-FreeList<NUM_BUCKETS>::find_chunk_ptr_for_size(size_t size,
-                                               bool non_null) const {
-  size_t chunk_ptr = 0;
-  for (chunk_ptr = 0u; chunk_ptr < sizes_.size(); chunk_ptr++) {
-    if (sizes_[chunk_ptr] >= size &&
-        (!non_null || chunks_[chunk_ptr] != nullptr)) {
-      break;
-    }
+LIBC_INLINE void FreeList::pop() { remove(begin_); }
+
+LIBC_INLINE void FreeList::remove(Node *node) {
+  LIBC_ASSERT(begin_ && "cannot remove from empty list");
+  if (node == node->next) {
+    LIBC_ASSERT(node == begin_ &&
+                "a self-referential node must be the only element");
+    begin_ = nullptr;
+  } else {
+    node->prev->next = node->next;
+    node->next->prev = node->prev;
+    if (begin_ == node)
+      begin_ = node->next;
   }
-
-  return chunk_ptr;
 }
 
 } // namespace LIBC_NAMESPACE_DECL
diff --git a/libc/src/__support/freelist_heap.h b/libc/src/__support/freelist_heap.h
index 6c860d039553ab..7636d431f6bc26 100644
--- a/libc/src/__support/freelist_heap.h
+++ b/libc/src/__support/freelist_heap.h
@@ -12,7 +12,7 @@
 #include <stddef.h>
 
 #include "block.h"
-#include "freelist.h"
+#include "freestore.h"
 #include "src/__support/CPP/optional.h"
 #include "src/__support/CPP/span.h"
 #include "src/__support/libc_assert.h"
@@ -30,21 +30,14 @@ using cpp::span;
 
 inline constexpr bool IsPow2(size_t x) { return x && (x & (x - 1)) == 0; }
 
-static constexpr cpp::array<size_t, 6> DEFAULT_BUCKETS{16,  32,  64,
-                                                       128, 256, 512};
-
-template <size_t NUM_BUCKETS = DEFAULT_BUCKETS.size()> class FreeListHeap {
+class FreeListHeap {
 public:
   using BlockType = Block<>;
-  using FreeListType = FreeList<NUM_BUCKETS>;
-
-  static constexpr size_t MIN_ALIGNMENT =
-      cpp::max(BlockType::ALIGNMENT, alignof(max_align_t));
 
-  constexpr FreeListHeap() : begin_(&_end), end_(&__llvm_libc_heap_limit) {}
+  constexpr FreeListHeap() : begin(&_end), end(&__llvm_libc_heap_limit) {}
 
   constexpr FreeListHeap(span<cpp::byte> region)
-      : begin_(region.begin()), end_(region.end()) {}
+      : begin(region.begin()), end(region.end()) {}
 
   void *allocate(size_t size);
   void *aligned_allocate(size_t alignment, size_t size);
@@ -54,89 +47,75 @@ template <size_t NUM_BUCKETS = DEFAULT_BUCKETS.size()> class FreeListHeap {
   void *realloc(void *ptr, size_t size);
   void *calloc(size_t num, size_t size);
 
-  cpp::span<cpp::byte> region() const { return {begin_, end_}; }
+  cpp::span<cpp::byte> region() const { return {begin, end}; }
 
 private:
   void init();
 
   void *allocate_impl(size_t alignment, size_t size);
 
-  span<cpp::byte> block_to_span(BlockType *block) {
+  span<cpp::byte> block_to_span(Block<> *block) {
     return span<cpp::byte>(block->usable_space(), block->inner_size());
   }
 
-  bool is_valid_ptr(void *ptr) { return ptr >= begin_ && ptr < end_; }
+  bool is_valid_ptr(void *ptr) { return ptr >= begin && ptr < end; }
 
-  bool is_initialized_ = false;
-  cpp::byte *begin_;
-  cpp::byte *end_;
-  FreeListType freelist_{DEFAULT_BUCKETS};
+  cpp::byte *begin;
+  cpp::byte *end;
+  bool is_initialized = false;
+  FreeStore free_store;
 };
 
-template <size_t BUFF_SIZE, size_t NUM_BUCKETS = DEFAULT_BUCKETS.size()>
-class FreeListHeapBuffer : public FreeListHeap<NUM_BUCKETS> {
-  using parent = FreeListHeap<NUM_BUCKETS>;
-  using FreeListNode = typename parent::FreeListType::FreeListNode;
-
+template <size_t BUFF_SIZE> class FreeListHeapBuffer : public FreeListHeap {
 public:
-  constexpr FreeListHeapBuffer()
-      : FreeListHeap<NUM_BUCKETS>{buffer}, buffer{} {}
+  constexpr FreeListHeapBuffer() : FreeListHeap{buffer}, buffer{} {}
 
 private:
   cpp::byte buffer[BUFF_SIZE];
 };
 
-template <size_t NUM_BUCKETS> void FreeListHeap<NUM_BUCKETS>::init() {
-  LIBC_ASSERT(!is_initialized_ && "duplicate initialization");
-  auto result = BlockType::init(region());
-  BlockType *block = *result;
-  freelist_.add_chunk(block_to_span(block));
-  is_initialized_ = true;
+inline void FreeListHeap::init() {
+  LIBC_ASSERT(!is_initialized && "duplicate initialization");
+  auto result = Block<>::init(region());
+  Block<> *block = *result;
+  free_store.set_range({0, cpp::bit_ceil(block->inner_size())});
+  free_store.insert(block);
+  is_initialized = true;
 }
 
-template <size_t NUM_BUCKETS>
-void *FreeListHeap<NUM_BUCKETS>::allocate_impl(size_t alignment, size_t size) {
+inline void *FreeListHeap::allocate_impl(size_t alignment, size_t size) {
   if (size == 0)
     return nullptr;
 
-  if (!is_initialized_)
+  if (!is_initialized)
     init();
 
-  // Find a chunk in the freelist. Split it if needed, then return.
-  auto chunk =
-      freelist_.find_chunk_if([alignment, size](span<cpp::byte> chunk) {
-        BlockType *block = BlockType::from_usable_space(chunk.data());
-        return block->can_allocate(alignment, size);
-      });
+  size_t request_size =
+      alignment <= alignof(max_align_t) ? size : size + alignment - 1;
 
-  if (chunk.data() == nullptr)
+  Block<> *block = free_store.remove_best_fit(request_size);
+  if (!block)
     return nullptr;
-  freelist_.remove_chunk(chunk);
 
-  BlockType *chunk_block = BlockType::from_usable_space(chunk.data());
-  LIBC_ASSERT(!chunk_block->used());
+  LIBC_ASSERT(block->can_allocate(alignment, size) &&
+              "block should always be large enough to allocate at the correct "
+              "alignment");
 
-  // Split that chunk. If there's a leftover chunk, add it to the freelist
-  auto block_info = BlockType::allocate(chunk_block, alignment, size);
+  auto block_info = Block<>::allocate(block, alignment, size);
   if (block_info.next)
-    freelist_.add_chunk(block_to_span(block_info.next));
+    free_store.insert(block_info.next);
   if (block_info.prev)
-    freelist_.add_chunk(block_to_span(block_info.prev));
-  chunk_block = block_info.block;
-
-  chunk_block->mark_used();
+    free_store.insert(block_info.prev);
 
-  return chunk_block->usable_space();
+  block_info.block->mark_used();
+  return block_info.block->usable_space();
 }
 
-template <size_t NUM_BUCKETS>
-void *FreeListHeap<NUM_BUCKETS>::allocate(size_t size) {
-  return allocate_impl(MIN_ALIGNMENT, size);
+inline void *FreeListHeap::allocate(size_t size) {
+  return allocate_impl(alignof(max_align_t), size);
 }
 
-template <size_t NUM_BUCKETS>
-void *FreeListHeap<NUM_BUCKETS>::aligned_allocate(size_t alignment,
-                                                  size_t size) {
+inline void *FreeListHeap::aligned_allocate(size_t alignment, size_t size) {
   // The alignment must be an integral power of two.
   if (!IsPow2(alignment))
     return nullptr;
@@ -148,38 +127,37 @@ void *FreeListHeap<NUM_BUCKETS>::aligned_allocate(size_t alignment,
   return allocate_impl(alignment, size);
 }
 
-template <size_t NUM_BUCKETS> void FreeListHeap<NUM_BUCKETS>::free(void *ptr) {
+inline void FreeListHeap::free(void *ptr) {
   cpp::byte *bytes = static_cast<cpp::byte *>(ptr);
 
   LIBC_ASSERT(is_valid_ptr(bytes) && "Invalid pointer");
 
-  BlockType *chunk_block = BlockType::from_usable_space(bytes);
-  LIBC_ASSERT(chunk_block->next() && "sentinel last block cannot be freed");
-  LIBC_ASSERT(chunk_block->used() && "The block is not in-use");
-  chunk_block->mark_free();
+  Block<> *block = Block<>::from_usable_space(bytes);
+  LIBC_ASSERT(block->next() && "sentinel last block cannot be freed");
+  LIBC_ASSERT(block->used() && "double free");
+  block->mark_free();
 
   // Can we combine with the left or right blocks?
-  BlockType *prev_free = chunk_block->prev_free();
-  BlockType *next = chunk_block->next();
+  Block<> *prev_free = block->prev_free();
+  Block<> *next = block->next();
 
   if (prev_free != nullptr) {
-    // Remove from freelist and merge
-    freelist_.remove_chunk(block_to_span(prev_free));
-    chunk_block = prev_free;
-    chunk_block->merge_next();
+    // Remove from free store and merge.
+    free_store.remove(prev_free);
+    block = prev_free;
+    block->merge_next();
   }
   if (!next->used()) {
-    freelist_.remove_chunk(block_to_span(next));
-    chunk_block->merge_next();
+    free_store.remove(next);
+    block->merge_next();
   }
   // Add back to the freelist
-  freelist_.add_chunk(block_to_span(chunk_block));
+  free_store.insert(block);
 }
 
 // Follows constract of the C standard realloc() function
 // If ptr is free'd, will return nullptr.
-template <size_t NUM_BUCKETS>
-void *FreeListHeap<NUM_BUCKETS>::realloc(void *ptr, size_t size) {
+inline void *FreeListHeap::realloc(void *ptr, size_t size) {
   if (size == 0) {
     free(ptr);
     return nullptr;
@@ -194,10 +172,10 @@ void *FreeListHeap<NUM_BUCKETS>::realloc(void *ptr, size_t size) {
   if (!is_valid_ptr(bytes))
     return nullptr;
 
-  BlockType *chunk_block = BlockType::from_usable_space(bytes);
-  if (!chunk_block->used())
+  Block<> *block = Block<>::from_usable_space(bytes);
+  if (!block->used())
     return nullptr;
-  size_t old_size = chunk_block->inner_size();
+  size_t old_size = block->inner_size();
 
   // Do nothing and return ptr if the required memory size is smaller than
   // the current size.
@@ -214,15 +192,14 @@ void *FreeListHeap<NUM_BUCKETS>::realloc(void *ptr, size...
[truncated]

@mysterymath
Copy link
Contributor Author

@nopsledder

Copy link
Contributor

@michaelrj-google michaelrj-google left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks fine overall, I haven't done a deep review of the logic but I did comment on a few style things.

BlockType *block = *result;
freelist_.add_chunk(block_to_span(block));
is_initialized_ = true;
inline void FreeListHeap::init() {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

inline -> LIBC_INLINE in multiple places

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done.

@@ -0,0 +1,253 @@
//===-- Interface for freetrie
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: formatting

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done.

using LIBC_NAMESPACE::cpp::array;
using LIBC_NAMESPACE::cpp::byte;
using LIBC_NAMESPACE::cpp::span;
namespace LIBC_NAMESPACE_DECL {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In General we try to avoid putting the tests inside of the LIBC_NAMESPACE to ensure that we're getting our implementation of a function instead of one pulled from the system. I think it's probably fine to do using here since it's only testing internals, but I'd like to avoid the namespace LIBC_NAMESPACE_DECL.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done.

Copy link
Contributor

@nopsledder nopsledder left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for this! Most of my comments are high level; let me know if you want to discuss more.

class Node {
public:
/// @returns The block containing this node.
Block<> *block() const {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I generally prefer to have a overrides like const Block<>* block() const and Block<>* block() in order to better preserve constiness through various calls.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done.

public:
// Remove copy/move ctors
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Recommend keeping these unless you have a reason not to.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It actually makes sense to trivially copy a FreeList or a FreeTrie, since this is a non-owning reference to the data structure. Their semantics are essentially that of a Node pointer.

// If we get here, we've checked every block in every bucket. There's
// nothing that can support this allocation.
return span<cpp::byte>();
LIBC_INLINE void FreeList::push(Block<> *block) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These were previously in the header file because they were templated. Do they need to still be inlined? If so, could you provide some rationale?

The same applies to other previously templated classes as well.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Honestly it was just expedience. I do think it makes sense to ensure visibility for anything that's overwhelmingly likely to be inlined, particularly anything that's used once, since embedded mallocs are quite often implemented as a single file, and that allows maximal inlining. TU separation is mostly a matter of organizational convenience, since the files involved are fairly small.

Still, I've gone through and broken out functions that are likely not to be inlined when optimizing for size (basically anything not small and used more than once). We can reexamine with specific performance numbers if we need to.

return true;
LIBC_INLINE void FreeList::push(Node *node) {
if (begin_) {
LIBC_ASSERT(Block<>::from_usable_space(node)->outer_size() ==
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit, while I'm thinking about it: The code that the Block type was taken from templated for various reasons, but it seems like everything here just uses the defaults. This is probably for another PR, but should Block be made non-templated? It possibly could still be compile-time configurable.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Generally agree; this is something that I wanted to do as a standalone NFC change.

@@ -1,4 +1,4 @@
//===-- Interface for freelist_malloc -------------------------------------===//
//===-- Interface for freelist --------------------------------------------===//
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just checking: there isn't a reusable intrusive forward list implementation already available, is there? The code this was originally taken is replacing this bespoke implementation with a more generic one, and it might make sense to do the same here if it's available.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Couldn't find any accessible from libc, but thanks; it was good to check.

/// and upper subtries.
class Node : public FreeList::Node {
/// Return an abitrary leaf in the subtrie.
Node &leaf();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

debatable: Since this is only needed by FreeTrie::remove, and FreeTrie is already a friend, I might suggesting getting rid of this method and moving that code directly into remove. It's just feels like an odd bit of interface.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good call; there's already a comment in remove about why a leaf is selected, and the implementation is quite obvious (and just 2 lines) given that context.

@@ -28,23 +30,23 @@ using LIBC_NAMESPACE::freelist_heap;
// made in tests leak and aren't free'd. This is fine for the purposes of this
// test file.
#define TEST_FOR_EACH_ALLOCATOR(TestCase, BufferSize) \
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is leftover from the code it was taken from, which has several different allocators. Perhaps this macro isn't needed here, and regular test fixtures would work just as well?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It still is trying two variants: the global heap and one instantiated locally. I couldn't immediately think of a way to rewrite it; maybe parameterized tests would work? Not sure whether that would end up more readable though.

return block->can_allocate(alignment, size);
});
size_t request_size =
alignment <= alignof(max_align_t) ? size : size + alignment - 1;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Possible integer overflow here.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done.

@@ -214,15 +193,14 @@ void *FreeListHeap<NUM_BUCKETS>::realloc(void *ptr, size_t size) {
return new_ptr;
}

template <size_t NUM_BUCKETS>
void *FreeListHeap<NUM_BUCKETS>::calloc(size_t num, size_t size) {
LIBC_INLINE void *FreeListHeap::calloc(size_t num, size_t size) {
void *ptr = allocate(num * size);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Possible integer overflow here.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed.

@@ -214,15 +193,14 @@ void *FreeListHeap<NUM_BUCKETS>::realloc(void *ptr, size_t size) {
return new_ptr;
}

template <size_t NUM_BUCKETS>
void *FreeListHeap<NUM_BUCKETS>::calloc(size_t num, size_t size) {
LIBC_INLINE void *FreeListHeap::calloc(size_t num, size_t size) {
void *ptr = allocate(num * size);
if (ptr != nullptr)
LIBC_NAMESPACE::inline_memset(ptr, 0, num * size);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'me not at all sure here, but would something like std::fill that could operate on words instead of bytes be faster here?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should use libc's optimized memset implementation, so it should work a word at a time whenever appropriate, or even using vector instructions when available.

@mysterymath
Copy link
Contributor Author

I wasn't sufficiently confident that this worked correctly, so I wrote a fuzzer test. Thankfully, this found quite a few issues, so I've fixed those and included the fuzzer. Hooray for property based testing!

mysterymath added a commit to mysterymath/llvm-project that referenced this pull request Nov 12, 2024
This prevents a conflict with the Linux system endian.h when built in
overlay mode for CPP files in __support.

This issue appeared in PR llvm#106259.
mysterymath added a commit that referenced this pull request Nov 13, 2024
This prevents a conflict with the Linux system endian.h when built in
overlay mode for CPP files in __support.

This issue appeared in PR #106259.
Copy link
Contributor

@michaelrj-google michaelrj-google left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Some minor comments, I didn't notice anything wrong with it but I'm not super confident that I understood it fully.

#include "src/string/memory_utils/inline_memmove.h"
#include "src/string/memory_utils/inline_memset.h"

using namespace LIBC_NAMESPACE;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: generally in tests we recommend not doing using namespace LIBC_NAMESPACE so it's clear what's coming from LLVM-libc.

This is also useful for differential fuzzing where we compare our internal implementation with the public one. Not a big deal here since everything is coming from LLVM-libc, but something to keep in mind.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, done.

Comment on lines +66 to +69
LIBC_ASSERT(!block->used() &&
"only free blocks can be placed on free lists");
LIBC_ASSERT(block->inner_size_free() >= sizeof(FreeList) &&
"block too small to accomodate free list node");
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would making this fail in non-debug mode be useful? This seems like the sort of thing that would be useful to catch at runtime.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should never occur at runtime. push is only called by the FreeTrie's push, which has even larger size requirements, and FreeStore's insert, which has a check to make it a no-op if the block is too small. Blocks that are too small can never effectively be added to the free store, since there's no way to track them. But their smallness would also mess with the free list selection logic in FreeStore, so the case is handled at that level (i.e., there's no need to keep track of a freelist that intrinsically must be empty).

128, 256, 512};

template <size_t NUM_BUCKETS = DEFAULT_BUCKETS.size()> class FreeListHeap {
class FreeListHeap {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I like FreelistHeapAlloc or similar to make it clear this is an allocator. "Heap" is what we call the memory we allocate outside of the stack, but it's also the name of a generic data structure.

/// @returns The lower half of the size range.
LIBC_INLINE SizeRange lower() const { return {min, width / 2}; }

/// @returns The lower half of the size range.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: fix this comment

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done, thanks.

@mysterymath
Copy link
Contributor Author

AFAICT the buildkite issue is a flake with the new generate_test_report.py; I've reported this in #113447.

This reworks the free store implementation in libc's malloc to use a
dlmalloc-style binary trie of circularly linked FIFO free lists. This
data structure can be maintained in logarithmic time, but it still
permits a relatively small implementation compared to other
logarithmic-time ordered maps.

The implementation doesn't do the various bitwise tricks or
optimizations used in actual dlmalloc; it instead optimizes for
(relative) readability and minimum code size. Specific optimization can
be added as necessary given future profiling.
These were found almost immediately, and some of them were quite tricky.
Hooray for fuzzing!
@mysterymath
Copy link
Contributor Author

The CI flake has been fixed, and it looks green. Friendly ping; anything left to do on this one?

Copy link
Contributor

@PiJoules PiJoules left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM Thanks!

@mysterymath mysterymath merged commit c3207c3 into llvm:main Nov 20, 2024
7 checks passed
@llvm-ci
Copy link
Collaborator

llvm-ci commented Nov 20, 2024

LLVM Buildbot has detected a new failure on builder libc-aarch64-ubuntu-dbg running on libc-aarch64-ubuntu while building libc at step 4 "annotate".

Full details are available at: https://lab.llvm.org/buildbot/#/builders/104/builds/10960

Here is the relevant piece of the build log for the reference
Step 4 (annotate) failure: 'python ../llvm-zorg/zorg/buildbot/builders/annotated/libc-linux.py ...' (failure)
...
[136/994] Running unit test libc.test.src.math.f16mul_test.__unit__
[==========] Running 2 tests from 1 test suite.
[ RUN      ] LlvmLibcMulTest.SubnormalRange
[       OK ] LlvmLibcMulTest.SubnormalRange (67 ms)
[ RUN      ] LlvmLibcMulTest.NormalRange
[       OK ] LlvmLibcMulTest.NormalRange (70 ms)
Ran 2 tests.  PASS: 2  FAIL: 0
[137/994] Linking CXX executable projects/libc/test/src/__support/libc.test.src.__support.freelist_test.__unit__.__build__
[138/994] Linking CXX executable projects/libc/test/src/__support/libc.test.src.__support.freetrie_test.__unit__.__build__
[139/994] Running unit test libc.test.src.__support.freelist_test.__unit__
FAILED: projects/libc/test/src/__support/CMakeFiles/libc.test.src.__support.freelist_test.__unit__ 
cd /home/libc-buildbot/libc-aarch64-ubuntu/libc-aarch64-ubuntu/build/projects/libc/test/src/__support && /home/libc-buildbot/libc-aarch64-ubuntu/libc-aarch64-ubuntu/build/projects/libc/test/src/__support/libc.test.src.__support.freelist_test.__unit__.__build__
[==========] Running 1 test from 1 test suite.
[ RUN      ] LlvmLibcFreeList.FreeList
libc.test.src.__support.freelist_test.__unit__.__build__: /home/libc-buildbot/libc-aarch64-ubuntu/libc-aarch64-ubuntu/llvm-project/libc/src/__support/freelist.cpp:17: void __llvm_libc_20_0_0_git::FreeList::push(__llvm_libc_20_0_0_git::FreeList::Node *): Assertion `Block<>::from_usable_space(node)->outer_size() == begin_->block()->outer_size() && "freelist entries must have the same size"' failed.
Aborted
[140/994] Running unit test libc.test.src.__support.freetrie_test.__unit__
[==========] Running 5 tests from 1 test suite.
[ RUN      ] LlvmLibcFreeTrie.FindBestFitRoot
[       OK ] LlvmLibcFreeTrie.FindBestFitRoot (5 us)
[ RUN      ] LlvmLibcFreeTrie.FindBestFitLower
[       OK ] LlvmLibcFreeTrie.FindBestFitLower (2 us)
[ RUN      ] LlvmLibcFreeTrie.FindBestFitUpper
[       OK ] LlvmLibcFreeTrie.FindBestFitUpper (3 us)
[ RUN      ] LlvmLibcFreeTrie.FindBestFitLowerAndUpper
[       OK ] LlvmLibcFreeTrie.FindBestFitLowerAndUpper (3 us)
[ RUN      ] LlvmLibcFreeTrie.Remove
[       OK ] LlvmLibcFreeTrie.Remove (4 us)
Ran 5 tests.  PASS: 5  FAIL: 0
[141/994] Linking CXX executable projects/libc/test/src/__support/libc.test.src.__support.freestore_test.__unit__.__build__
[142/994] Running unit test libc.test.src.math.sinpif16_test.__unit__.__NO_ROUND_OPT
[==========] Running 2 tests from 1 test suite.
[ RUN      ] LlvmLibcSinpif16Test.PositiveRange
[       OK ] LlvmLibcSinpif16Test.PositiveRange (168 ms)
[ RUN      ] LlvmLibcSinpif16Test.NegativeRange
[       OK ] LlvmLibcSinpif16Test.NegativeRange (166 ms)
Ran 2 tests.  PASS: 2  FAIL: 0
[143/994] Running unit test libc.test.src.math.erff_test.__unit__
[==========] Running 3 tests from 1 test suite.
[ RUN      ] LlvmLibcErffTest.SpecialNumbers
[       OK ] LlvmLibcErffTest.SpecialNumbers (6 us)
[ RUN      ] LlvmLibcErffTest.TrickyInputs
[       OK ] LlvmLibcErffTest.TrickyInputs (351 us)
[ RUN      ] LlvmLibcErffTest.InFloatRange
 Test Rounding To Nearest...
 Log failed: 0/234562/234562 tests.
   Max ULPs is at most: 0.
 Test Rounding Downward...
 Log failed: 0/234562/234562 tests.
Step 7 (libc-unit-tests) failure: libc-unit-tests (failure)
...
[136/994] Running unit test libc.test.src.math.f16mul_test.__unit__
[==========] Running 2 tests from 1 test suite.
[ RUN      ] LlvmLibcMulTest.SubnormalRange
[       OK ] LlvmLibcMulTest.SubnormalRange (67 ms)
[ RUN      ] LlvmLibcMulTest.NormalRange
[       OK ] LlvmLibcMulTest.NormalRange (70 ms)
Ran 2 tests.  PASS: 2  FAIL: 0
[137/994] Linking CXX executable projects/libc/test/src/__support/libc.test.src.__support.freelist_test.__unit__.__build__
[138/994] Linking CXX executable projects/libc/test/src/__support/libc.test.src.__support.freetrie_test.__unit__.__build__
[139/994] Running unit test libc.test.src.__support.freelist_test.__unit__
FAILED: projects/libc/test/src/__support/CMakeFiles/libc.test.src.__support.freelist_test.__unit__ 
cd /home/libc-buildbot/libc-aarch64-ubuntu/libc-aarch64-ubuntu/build/projects/libc/test/src/__support && /home/libc-buildbot/libc-aarch64-ubuntu/libc-aarch64-ubuntu/build/projects/libc/test/src/__support/libc.test.src.__support.freelist_test.__unit__.__build__
[==========] Running 1 test from 1 test suite.
[ RUN      ] LlvmLibcFreeList.FreeList
libc.test.src.__support.freelist_test.__unit__.__build__: /home/libc-buildbot/libc-aarch64-ubuntu/libc-aarch64-ubuntu/llvm-project/libc/src/__support/freelist.cpp:17: void __llvm_libc_20_0_0_git::FreeList::push(__llvm_libc_20_0_0_git::FreeList::Node *): Assertion `Block<>::from_usable_space(node)->outer_size() == begin_->block()->outer_size() && "freelist entries must have the same size"' failed.
Aborted
[140/994] Running unit test libc.test.src.__support.freetrie_test.__unit__
[==========] Running 5 tests from 1 test suite.
[ RUN      ] LlvmLibcFreeTrie.FindBestFitRoot
[       OK ] LlvmLibcFreeTrie.FindBestFitRoot (5 us)
[ RUN      ] LlvmLibcFreeTrie.FindBestFitLower
[       OK ] LlvmLibcFreeTrie.FindBestFitLower (2 us)
[ RUN      ] LlvmLibcFreeTrie.FindBestFitUpper
[       OK ] LlvmLibcFreeTrie.FindBestFitUpper (3 us)
[ RUN      ] LlvmLibcFreeTrie.FindBestFitLowerAndUpper
[       OK ] LlvmLibcFreeTrie.FindBestFitLowerAndUpper (3 us)
[ RUN      ] LlvmLibcFreeTrie.Remove
[       OK ] LlvmLibcFreeTrie.Remove (4 us)
Ran 5 tests.  PASS: 5  FAIL: 0
[141/994] Linking CXX executable projects/libc/test/src/__support/libc.test.src.__support.freestore_test.__unit__.__build__
[142/994] Running unit test libc.test.src.math.sinpif16_test.__unit__.__NO_ROUND_OPT
[==========] Running 2 tests from 1 test suite.
[ RUN      ] LlvmLibcSinpif16Test.PositiveRange
[       OK ] LlvmLibcSinpif16Test.PositiveRange (168 ms)
[ RUN      ] LlvmLibcSinpif16Test.NegativeRange
[       OK ] LlvmLibcSinpif16Test.NegativeRange (166 ms)
Ran 2 tests.  PASS: 2  FAIL: 0
[143/994] Running unit test libc.test.src.math.erff_test.__unit__
[==========] Running 3 tests from 1 test suite.
[ RUN      ] LlvmLibcErffTest.SpecialNumbers
[       OK ] LlvmLibcErffTest.SpecialNumbers (6 us)
[ RUN      ] LlvmLibcErffTest.TrickyInputs
[       OK ] LlvmLibcErffTest.TrickyInputs (351 us)
[ RUN      ] LlvmLibcErffTest.InFloatRange
 Test Rounding To Nearest...
 Log failed: 0/234562/234562 tests.
   Max ULPs is at most: 0.
 Test Rounding Downward...
 Log failed: 0/234562/234562 tests.

@llvm-ci
Copy link
Collaborator

llvm-ci commented Nov 20, 2024

LLVM Buildbot has detected a new failure on builder libc-aarch64-ubuntu-fullbuild-dbg running on libc-aarch64-ubuntu while building libc at step 4 "annotate".

Full details are available at: https://lab.llvm.org/buildbot/#/builders/71/builds/10949

Here is the relevant piece of the build log for the reference
Step 4 (annotate) failure: 'python ../llvm-zorg/zorg/buildbot/builders/annotated/libc-linux.py ...' (failure)
...
[454/893] Building CXX object projects/libc/test/src/__support/CMakeFiles/libc.test.src.__support.freetrie_test.__unit__.__build__.dir/freetrie_test.cpp.o
[455/893] Linking CXX executable projects/libc/test/src/__support/libc.test.src.__support.freelist_test.__unit__.__build__
[456/893] Running unit test libc.test.src.math.smoke.copysign_test.__unit__.__NO_MISC_MATH_BASIC_OPS_OPT
[==========] Running 2 tests from 1 test suite.
[ RUN      ] LlvmLibcCopySignTest.SpecialNumbers
[       OK ] LlvmLibcCopySignTest.SpecialNumbers (4 us)
[ RUN      ] LlvmLibcCopySignTest.Range
[       OK ] LlvmLibcCopySignTest.Range (30 ms)
Ran 2 tests.  PASS: 2  FAIL: 0
[457/893] Running unit test libc.test.src.__support.freelist_test.__unit__
FAILED: projects/libc/test/src/__support/CMakeFiles/libc.test.src.__support.freelist_test.__unit__ 
cd /home/libc-buildbot/libc-aarch64-ubuntu/libc-aarch64-ubuntu-fullbuild-dbg/build/projects/libc/test/src/__support && /home/libc-buildbot/libc-aarch64-ubuntu/libc-aarch64-ubuntu-fullbuild-dbg/build/projects/libc/test/src/__support/libc.test.src.__support.freelist_test.__unit__.__build__
[==========] Running 1 test from 1 test suite.
[ RUN      ] LlvmLibcFreeList.FreeList
/home/libc-buildbot/libc-aarch64-ubuntu/libc-aarch64-ubuntu-fullbuild-dbg/llvm-project/libc/src/__support/freelist.cpp:17: Assertion failed: 'Block<>::from_usable_space(node)->outer_size() == begin_->block()->outer_size() && "freelist entries must have the same size"' in function: 'void __llvm_libc_20_0_0_git::FreeList::push(__llvm_libc_20_0_0_git::FreeList::Node *)'
[458/893] Running unit test libc.test.src.math.smoke.ceilf_test.__unit__.__NO_ROUND_OPT
[==========] Running 3 tests from 1 test suite.
[ RUN      ] LlvmLibcCeilTest.SpecialNumbers
[       OK ] LlvmLibcCeilTest.SpecialNumbers (3 us)
[ RUN      ] LlvmLibcCeilTest.RoundedNubmers
[       OK ] LlvmLibcCeilTest.RoundedNubmers (1 us)
[ RUN      ] LlvmLibcCeilTest.Fractions
[       OK ] LlvmLibcCeilTest.Fractions (3 us)
Ran 3 tests.  PASS: 3  FAIL: 0
[459/893] Running unit test libc.test.src.string.memory_utils.utils_test.__unit__
[==========] Running 48 tests from 1 test suite.
[ RUN      ] LlvmLibcOpTest.Memcpy [ParamType = __llvm_libc_20_0_0_git::builtin::Memcpy<64>]
[       OK ] LlvmLibcOpTest.Memcpy [ParamType = __llvm_libc_20_0_0_git::builtin::Memcpy<64>] (388 us)
[ RUN      ] LlvmLibcOpTest.Memcpy [ParamType = __llvm_libc_20_0_0_git::builtin::Memcpy<32>]
[       OK ] LlvmLibcOpTest.Memcpy [ParamType = __llvm_libc_20_0_0_git::builtin::Memcpy<32>] (113 us)
[ RUN      ] LlvmLibcOpTest.Memcpy [ParamType = __llvm_libc_20_0_0_git::builtin::Memcpy<16>]
[       OK ] LlvmLibcOpTest.Memcpy [ParamType = __llvm_libc_20_0_0_git::builtin::Memcpy<16>] (39 us)
[ RUN      ] LlvmLibcOpTest.Memcpy [ParamType = __llvm_libc_20_0_0_git::builtin::Memcpy<8>]
[       OK ] LlvmLibcOpTest.Memcpy [ParamType = __llvm_libc_20_0_0_git::builtin::Memcpy<8>] (18 us)
[ RUN      ] LlvmLibcOpTest.Memcpy [ParamType = __llvm_libc_20_0_0_git::builtin::Memcpy<4>]
[       OK ] LlvmLibcOpTest.Memcpy [ParamType = __llvm_libc_20_0_0_git::builtin::Memcpy<4>] (8 us)
[ RUN      ] LlvmLibcOpTest.Memcpy [ParamType = __llvm_libc_20_0_0_git::builtin::Memcpy<3>]
[       OK ] LlvmLibcOpTest.Memcpy [ParamType = __llvm_libc_20_0_0_git::builtin::Memcpy<3>] (6 us)
[ RUN      ] LlvmLibcOpTest.Memcpy [ParamType = __llvm_libc_20_0_0_git::builtin::Memcpy<2>]
[       OK ] LlvmLibcOpTest.Memcpy [ParamType = __llvm_libc_20_0_0_git::builtin::Memcpy<2>] (5 us)
[ RUN      ] LlvmLibcOpTest.Memcpy [ParamType = __llvm_libc_20_0_0_git::builtin::Memcpy<1>]
[       OK ] LlvmLibcOpTest.Memcpy [ParamType = __llvm_libc_20_0_0_git::builtin::Memcpy<1>] (3 us)
[ RUN      ] LlvmLibcOpTest.Memset [ParamType = __llvm_libc_20_0_0_git::generic::MemsetSequence<unsigned int, unsigned short, unsigned char>]
[       OK ] LlvmLibcOpTest.Memset [ParamType = __llvm_libc_20_0_0_git::generic::MemsetSequence<unsigned int, unsigned short, unsigned char>] (3 us)
[ RUN      ] LlvmLibcOpTest.Memset [ParamType = __llvm_libc_20_0_0_git::generic::MemsetSequence<unsigned short, unsigned char>]
[       OK ] LlvmLibcOpTest.Memset [ParamType = __llvm_libc_20_0_0_git::generic::MemsetSequence<unsigned short, unsigned char>] (2 us)
[ RUN      ] LlvmLibcOpTest.Memset [ParamType = __llvm_libc_20_0_0_git::generic::MemsetSequence<unsigned char, unsigned char>]
[       OK ] LlvmLibcOpTest.Memset [ParamType = __llvm_libc_20_0_0_git::generic::MemsetSequence<unsigned char, unsigned char>] (2 us)
[ RUN      ] LlvmLibcOpTest.Memset [ParamType = __llvm_libc_20_0_0_git::generic::Memset<__llvm_libc_20_0_0_git::cpp::array<unsigned char, 2>>]
Step 8 (libc-unit-tests) failure: libc-unit-tests (failure)
...
[454/893] Building CXX object projects/libc/test/src/__support/CMakeFiles/libc.test.src.__support.freetrie_test.__unit__.__build__.dir/freetrie_test.cpp.o
[455/893] Linking CXX executable projects/libc/test/src/__support/libc.test.src.__support.freelist_test.__unit__.__build__
[456/893] Running unit test libc.test.src.math.smoke.copysign_test.__unit__.__NO_MISC_MATH_BASIC_OPS_OPT
[==========] Running 2 tests from 1 test suite.
[ RUN      ] LlvmLibcCopySignTest.SpecialNumbers
[       OK ] LlvmLibcCopySignTest.SpecialNumbers (4 us)
[ RUN      ] LlvmLibcCopySignTest.Range
[       OK ] LlvmLibcCopySignTest.Range (30 ms)
Ran 2 tests.  PASS: 2  FAIL: 0
[457/893] Running unit test libc.test.src.__support.freelist_test.__unit__
FAILED: projects/libc/test/src/__support/CMakeFiles/libc.test.src.__support.freelist_test.__unit__ 
cd /home/libc-buildbot/libc-aarch64-ubuntu/libc-aarch64-ubuntu-fullbuild-dbg/build/projects/libc/test/src/__support && /home/libc-buildbot/libc-aarch64-ubuntu/libc-aarch64-ubuntu-fullbuild-dbg/build/projects/libc/test/src/__support/libc.test.src.__support.freelist_test.__unit__.__build__
[==========] Running 1 test from 1 test suite.
[ RUN      ] LlvmLibcFreeList.FreeList
/home/libc-buildbot/libc-aarch64-ubuntu/libc-aarch64-ubuntu-fullbuild-dbg/llvm-project/libc/src/__support/freelist.cpp:17: Assertion failed: 'Block<>::from_usable_space(node)->outer_size() == begin_->block()->outer_size() && "freelist entries must have the same size"' in function: 'void __llvm_libc_20_0_0_git::FreeList::push(__llvm_libc_20_0_0_git::FreeList::Node *)'
[458/893] Running unit test libc.test.src.math.smoke.ceilf_test.__unit__.__NO_ROUND_OPT
[==========] Running 3 tests from 1 test suite.
[ RUN      ] LlvmLibcCeilTest.SpecialNumbers
[       OK ] LlvmLibcCeilTest.SpecialNumbers (3 us)
[ RUN      ] LlvmLibcCeilTest.RoundedNubmers
[       OK ] LlvmLibcCeilTest.RoundedNubmers (1 us)
[ RUN      ] LlvmLibcCeilTest.Fractions
[       OK ] LlvmLibcCeilTest.Fractions (3 us)
Ran 3 tests.  PASS: 3  FAIL: 0
[459/893] Running unit test libc.test.src.string.memory_utils.utils_test.__unit__
[==========] Running 48 tests from 1 test suite.
[ RUN      ] LlvmLibcOpTest.Memcpy [ParamType = __llvm_libc_20_0_0_git::builtin::Memcpy<64>]
[       OK ] LlvmLibcOpTest.Memcpy [ParamType = __llvm_libc_20_0_0_git::builtin::Memcpy<64>] (388 us)
[ RUN      ] LlvmLibcOpTest.Memcpy [ParamType = __llvm_libc_20_0_0_git::builtin::Memcpy<32>]
[       OK ] LlvmLibcOpTest.Memcpy [ParamType = __llvm_libc_20_0_0_git::builtin::Memcpy<32>] (113 us)
[ RUN      ] LlvmLibcOpTest.Memcpy [ParamType = __llvm_libc_20_0_0_git::builtin::Memcpy<16>]
[       OK ] LlvmLibcOpTest.Memcpy [ParamType = __llvm_libc_20_0_0_git::builtin::Memcpy<16>] (39 us)
[ RUN      ] LlvmLibcOpTest.Memcpy [ParamType = __llvm_libc_20_0_0_git::builtin::Memcpy<8>]
[       OK ] LlvmLibcOpTest.Memcpy [ParamType = __llvm_libc_20_0_0_git::builtin::Memcpy<8>] (18 us)
[ RUN      ] LlvmLibcOpTest.Memcpy [ParamType = __llvm_libc_20_0_0_git::builtin::Memcpy<4>]
[       OK ] LlvmLibcOpTest.Memcpy [ParamType = __llvm_libc_20_0_0_git::builtin::Memcpy<4>] (8 us)
[ RUN      ] LlvmLibcOpTest.Memcpy [ParamType = __llvm_libc_20_0_0_git::builtin::Memcpy<3>]
[       OK ] LlvmLibcOpTest.Memcpy [ParamType = __llvm_libc_20_0_0_git::builtin::Memcpy<3>] (6 us)
[ RUN      ] LlvmLibcOpTest.Memcpy [ParamType = __llvm_libc_20_0_0_git::builtin::Memcpy<2>]
[       OK ] LlvmLibcOpTest.Memcpy [ParamType = __llvm_libc_20_0_0_git::builtin::Memcpy<2>] (5 us)
[ RUN      ] LlvmLibcOpTest.Memcpy [ParamType = __llvm_libc_20_0_0_git::builtin::Memcpy<1>]
[       OK ] LlvmLibcOpTest.Memcpy [ParamType = __llvm_libc_20_0_0_git::builtin::Memcpy<1>] (3 us)
[ RUN      ] LlvmLibcOpTest.Memset [ParamType = __llvm_libc_20_0_0_git::generic::MemsetSequence<unsigned int, unsigned short, unsigned char>]
[       OK ] LlvmLibcOpTest.Memset [ParamType = __llvm_libc_20_0_0_git::generic::MemsetSequence<unsigned int, unsigned short, unsigned char>] (3 us)
[ RUN      ] LlvmLibcOpTest.Memset [ParamType = __llvm_libc_20_0_0_git::generic::MemsetSequence<unsigned short, unsigned char>]
[       OK ] LlvmLibcOpTest.Memset [ParamType = __llvm_libc_20_0_0_git::generic::MemsetSequence<unsigned short, unsigned char>] (2 us)
[ RUN      ] LlvmLibcOpTest.Memset [ParamType = __llvm_libc_20_0_0_git::generic::MemsetSequence<unsigned char, unsigned char>]
[       OK ] LlvmLibcOpTest.Memset [ParamType = __llvm_libc_20_0_0_git::generic::MemsetSequence<unsigned char, unsigned char>] (2 us)
[ RUN      ] LlvmLibcOpTest.Memset [ParamType = __llvm_libc_20_0_0_git::generic::Memset<__llvm_libc_20_0_0_git::cpp::array<unsigned char, 2>>]

@llvm-ci
Copy link
Collaborator

llvm-ci commented Nov 20, 2024

LLVM Buildbot has detected a new failure on builder libc-x86_64-debian-gcc-fullbuild-dbg running on libc-x86_64-debian-fullbuild while building libc at step 4 "annotate".

Full details are available at: https://lab.llvm.org/buildbot/#/builders/131/builds/10797

Here is the relevant piece of the build log for the reference
Step 4 (annotate) failure: 'python ../llvm-zorg/zorg/buildbot/builders/annotated/libc-linux.py ...' (failure)
...
Ran 5 tests.  PASS: 5  FAIL: 0
[119/1111] Building CXX object projects/libc/src/__support/CMakeFiles/libc.src.__support.freelist.dir/freelist.cpp.o
[120/1111] Running unit test libc.test.src.math.nextafterf_test.__unit__
[==========] Running 2 tests from 1 test suite.
[ RUN      ] LlvmLibcNextAfterTest.TestNaN
[       OK ] LlvmLibcNextAfterTest.TestNaN (4 us)
[ RUN      ] LlvmLibcNextAfterTest.TestBoundaries
[       OK ] LlvmLibcNextAfterTest.TestBoundaries (16 us)
Ran 2 tests.  PASS: 2  FAIL: 0
[121/1111] Building CXX object projects/libc/src/__support/CMakeFiles/libc.src.__support.freetrie.dir/freetrie.cpp.o
FAILED: projects/libc/src/__support/CMakeFiles/libc.src.__support.freetrie.dir/freetrie.cpp.o 
/usr/bin/g++ -DLIBC_NAMESPACE=__llvm_libc_19_0_0_git -D_DEBUG -I/home/llvm-libc-buildbot/buildbot-worker/libc-x86_64-debian-fullbuild/libc-x86_64-debian-gcc-fullbuild-dbg/build/projects/libc/src/__support -I/home/llvm-libc-buildbot/buildbot-worker/libc-x86_64-debian-fullbuild/libc-x86_64-debian-gcc-fullbuild-dbg/llvm-project/libc/src/__support -I/home/llvm-libc-buildbot/buildbot-worker/libc-x86_64-debian-fullbuild/libc-x86_64-debian-gcc-fullbuild-dbg/llvm-project/libc -isystem /home/llvm-libc-buildbot/buildbot-worker/libc-x86_64-debian-fullbuild/libc-x86_64-debian-gcc-fullbuild-dbg/build/projects/libc/include -fPIC -fno-semantic-interposition -fvisibility-inlines-hidden -Werror=date-time -fno-lifetime-dse -Wall -Wextra -Wno-unused-parameter -Wwrite-strings -Wcast-qual -Wno-missing-field-initializers -pedantic -Wno-long-long -Wimplicit-fallthrough -Wno-maybe-uninitialized -Wno-nonnull -Wno-class-memaccess -Wno-redundant-move -Wno-pessimizing-move -Wno-noexcept-type -Wdelete-non-virtual-dtor -Wsuggest-override -Wno-comment -Wno-misleading-indentation -Wctad-maybe-unsupported -fdiagnostics-color -g -DLIBC_QSORT_IMPL=LIBC_QSORT_QUICK_SORT -DLIBC_ADD_NULL_CHECKS -fpie -ffreestanding -DLIBC_FULL_BUILD -isystem/usr/lib/gcc/x86_64-linux-gnu/12//include -nostdinc -idirafter/usr/include -fno-builtin -fno-exceptions -fno-lax-vector-conversions -fno-unwind-tables -fno-asynchronous-unwind-tables -fno-rtti -ftrivial-auto-var-init=pattern -fno-omit-frame-pointer -mno-omit-leaf-frame-pointer -Wall -Wextra -Werror -Wconversion -Wno-sign-conversion -fext-numeric-literals -Wno-pedantic -Wimplicit-fallthrough -Wwrite-strings -Wextra-semi -std=c++17 -MD -MT projects/libc/src/__support/CMakeFiles/libc.src.__support.freetrie.dir/freetrie.cpp.o -MF projects/libc/src/__support/CMakeFiles/libc.src.__support.freetrie.dir/freetrie.cpp.o.d -o projects/libc/src/__support/CMakeFiles/libc.src.__support.freetrie.dir/freetrie.cpp.o -c /home/llvm-libc-buildbot/buildbot-worker/libc-x86_64-debian-fullbuild/libc-x86_64-debian-gcc-fullbuild-dbg/llvm-project/libc/src/__support/freetrie.cpp
In file included from /home/llvm-libc-buildbot/buildbot-worker/libc-x86_64-debian-fullbuild/libc-x86_64-debian-gcc-fullbuild-dbg/llvm-project/libc/src/__support/big_int.h:19,
                 from /home/llvm-libc-buildbot/buildbot-worker/libc-x86_64-debian-fullbuild/libc-x86_64-debian-gcc-fullbuild-dbg/llvm-project/libc/src/__support/integer_to_string.h:70,
                 from /home/llvm-libc-buildbot/buildbot-worker/libc-x86_64-debian-fullbuild/libc-x86_64-debian-gcc-fullbuild-dbg/llvm-project/libc/src/__support/libc_assert.h:26,
                 from /home/llvm-libc-buildbot/buildbot-worker/libc-x86_64-debian-fullbuild/libc-x86_64-debian-gcc-fullbuild-dbg/llvm-project/libc/src/__support/block.h:19,
                 from /home/llvm-libc-buildbot/buildbot-worker/libc-x86_64-debian-fullbuild/libc-x86_64-debian-gcc-fullbuild-dbg/llvm-project/libc/src/__support/freelist.h:12,
                 from /home/llvm-libc-buildbot/buildbot-worker/libc-x86_64-debian-fullbuild/libc-x86_64-debian-gcc-fullbuild-dbg/llvm-project/libc/src/__support/freetrie.h:12,
                 from /home/llvm-libc-buildbot/buildbot-worker/libc-x86_64-debian-fullbuild/libc-x86_64-debian-gcc-fullbuild-dbg/llvm-project/libc/src/__support/freetrie.cpp:9:
/home/llvm-libc-buildbot/buildbot-worker/libc-x86_64-debian-fullbuild/libc-x86_64-debian-gcc-fullbuild-dbg/llvm-project/libc/src/__support/freetrie.h: In member function ‘__llvm_libc_19_0_0_git::FreeTrie::Node* __llvm_libc_19_0_0_git::FreeTrie::find_best_fit(size_t)’:
/home/llvm-libc-buildbot/buildbot-worker/libc-x86_64-debian-fullbuild/libc-x86_64-debian-gcc-fullbuild-dbg/llvm-project/libc/src/__support/freetrie.h:185:55: error: suggest parentheses around ‘&&’ within ‘||’ [-Werror=parentheses]
  185 |           deferred_upper_range.min > best_fit->size() &&
      |           ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~
  186 |               "deferred upper subtrie should be outclassed by new best fit");
      |               ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/home/llvm-libc-buildbot/buildbot-worker/libc-x86_64-debian-fullbuild/libc-x86_64-debian-gcc-fullbuild-dbg/llvm-project/libc/src/__support/macros/optimization.h:29:51: note: in definition of macro ‘LIBC_UNLIKELY’
   29 |   LIBC_NAMESPACE::details::expects_bool_condition(x, false)
      |                                                   ^
/home/llvm-libc-buildbot/buildbot-worker/libc-x86_64-debian-fullbuild/libc-x86_64-debian-gcc-fullbuild-dbg/llvm-project/libc/src/__support/freetrie.h:183:7: note: in expansion of macro ‘LIBC_ASSERT’
  183 |       LIBC_ASSERT(
      |       ^~~~~~~~~~~
/home/llvm-libc-buildbot/buildbot-worker/libc-x86_64-debian-fullbuild/libc-x86_64-debian-gcc-fullbuild-dbg/llvm-project/libc/src/__support/freetrie.h:225:70: error: suggest parentheses around ‘&&’ within ‘||’ [-Werror=parentheses]
  225 |                   cur_range.upper().max() < deferred_upper_range.min &&
      |                   ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~
  226 |                       "old deferred upper subtrie should be outclassed by new");
      |                       ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/home/llvm-libc-buildbot/buildbot-worker/libc-x86_64-debian-fullbuild/libc-x86_64-debian-gcc-fullbuild-dbg/llvm-project/libc/src/__support/macros/optimization.h:29:51: note: in definition of macro ‘LIBC_UNLIKELY’
   29 |   LIBC_NAMESPACE::details::expects_bool_condition(x, false)
      |                                                   ^
/home/llvm-libc-buildbot/buildbot-worker/libc-x86_64-debian-fullbuild/libc-x86_64-debian-gcc-fullbuild-dbg/llvm-project/libc/src/__support/freetrie.h:224:7: note: in expansion of macro ‘LIBC_ASSERT’
  224 |       LIBC_ASSERT(!deferred_upper_trie ||
      |       ^~~~~~~~~~~
cc1plus: all warnings being treated as errors
[122/1111] Running unit test libc.test.src.math.fminf_test.__unit__.__NO_FMA_OPT
[==========] Running 5 tests from 1 test suite.
[ RUN      ] LlvmLibcFMinTest.NaN
[       OK ] LlvmLibcFMinTest.NaN (6 us)
[ RUN      ] LlvmLibcFMinTest.InfArg
[       OK ] LlvmLibcFMinTest.InfArg (5 us)
Step 8 (libc-unit-tests) failure: libc-unit-tests (failure)
...
Ran 5 tests.  PASS: 5  FAIL: 0
[119/1111] Building CXX object projects/libc/src/__support/CMakeFiles/libc.src.__support.freelist.dir/freelist.cpp.o
[120/1111] Running unit test libc.test.src.math.nextafterf_test.__unit__
[==========] Running 2 tests from 1 test suite.
[ RUN      ] LlvmLibcNextAfterTest.TestNaN
[       OK ] LlvmLibcNextAfterTest.TestNaN (4 us)
[ RUN      ] LlvmLibcNextAfterTest.TestBoundaries
[       OK ] LlvmLibcNextAfterTest.TestBoundaries (16 us)
Ran 2 tests.  PASS: 2  FAIL: 0
[121/1111] Building CXX object projects/libc/src/__support/CMakeFiles/libc.src.__support.freetrie.dir/freetrie.cpp.o
FAILED: projects/libc/src/__support/CMakeFiles/libc.src.__support.freetrie.dir/freetrie.cpp.o 
/usr/bin/g++ -DLIBC_NAMESPACE=__llvm_libc_19_0_0_git -D_DEBUG -I/home/llvm-libc-buildbot/buildbot-worker/libc-x86_64-debian-fullbuild/libc-x86_64-debian-gcc-fullbuild-dbg/build/projects/libc/src/__support -I/home/llvm-libc-buildbot/buildbot-worker/libc-x86_64-debian-fullbuild/libc-x86_64-debian-gcc-fullbuild-dbg/llvm-project/libc/src/__support -I/home/llvm-libc-buildbot/buildbot-worker/libc-x86_64-debian-fullbuild/libc-x86_64-debian-gcc-fullbuild-dbg/llvm-project/libc -isystem /home/llvm-libc-buildbot/buildbot-worker/libc-x86_64-debian-fullbuild/libc-x86_64-debian-gcc-fullbuild-dbg/build/projects/libc/include -fPIC -fno-semantic-interposition -fvisibility-inlines-hidden -Werror=date-time -fno-lifetime-dse -Wall -Wextra -Wno-unused-parameter -Wwrite-strings -Wcast-qual -Wno-missing-field-initializers -pedantic -Wno-long-long -Wimplicit-fallthrough -Wno-maybe-uninitialized -Wno-nonnull -Wno-class-memaccess -Wno-redundant-move -Wno-pessimizing-move -Wno-noexcept-type -Wdelete-non-virtual-dtor -Wsuggest-override -Wno-comment -Wno-misleading-indentation -Wctad-maybe-unsupported -fdiagnostics-color -g -DLIBC_QSORT_IMPL=LIBC_QSORT_QUICK_SORT -DLIBC_ADD_NULL_CHECKS -fpie -ffreestanding -DLIBC_FULL_BUILD -isystem/usr/lib/gcc/x86_64-linux-gnu/12//include -nostdinc -idirafter/usr/include -fno-builtin -fno-exceptions -fno-lax-vector-conversions -fno-unwind-tables -fno-asynchronous-unwind-tables -fno-rtti -ftrivial-auto-var-init=pattern -fno-omit-frame-pointer -mno-omit-leaf-frame-pointer -Wall -Wextra -Werror -Wconversion -Wno-sign-conversion -fext-numeric-literals -Wno-pedantic -Wimplicit-fallthrough -Wwrite-strings -Wextra-semi -std=c++17 -MD -MT projects/libc/src/__support/CMakeFiles/libc.src.__support.freetrie.dir/freetrie.cpp.o -MF projects/libc/src/__support/CMakeFiles/libc.src.__support.freetrie.dir/freetrie.cpp.o.d -o projects/libc/src/__support/CMakeFiles/libc.src.__support.freetrie.dir/freetrie.cpp.o -c /home/llvm-libc-buildbot/buildbot-worker/libc-x86_64-debian-fullbuild/libc-x86_64-debian-gcc-fullbuild-dbg/llvm-project/libc/src/__support/freetrie.cpp
In file included from /home/llvm-libc-buildbot/buildbot-worker/libc-x86_64-debian-fullbuild/libc-x86_64-debian-gcc-fullbuild-dbg/llvm-project/libc/src/__support/big_int.h:19,
                 from /home/llvm-libc-buildbot/buildbot-worker/libc-x86_64-debian-fullbuild/libc-x86_64-debian-gcc-fullbuild-dbg/llvm-project/libc/src/__support/integer_to_string.h:70,
                 from /home/llvm-libc-buildbot/buildbot-worker/libc-x86_64-debian-fullbuild/libc-x86_64-debian-gcc-fullbuild-dbg/llvm-project/libc/src/__support/libc_assert.h:26,
                 from /home/llvm-libc-buildbot/buildbot-worker/libc-x86_64-debian-fullbuild/libc-x86_64-debian-gcc-fullbuild-dbg/llvm-project/libc/src/__support/block.h:19,
                 from /home/llvm-libc-buildbot/buildbot-worker/libc-x86_64-debian-fullbuild/libc-x86_64-debian-gcc-fullbuild-dbg/llvm-project/libc/src/__support/freelist.h:12,
                 from /home/llvm-libc-buildbot/buildbot-worker/libc-x86_64-debian-fullbuild/libc-x86_64-debian-gcc-fullbuild-dbg/llvm-project/libc/src/__support/freetrie.h:12,
                 from /home/llvm-libc-buildbot/buildbot-worker/libc-x86_64-debian-fullbuild/libc-x86_64-debian-gcc-fullbuild-dbg/llvm-project/libc/src/__support/freetrie.cpp:9:
/home/llvm-libc-buildbot/buildbot-worker/libc-x86_64-debian-fullbuild/libc-x86_64-debian-gcc-fullbuild-dbg/llvm-project/libc/src/__support/freetrie.h: In member function ‘__llvm_libc_19_0_0_git::FreeTrie::Node* __llvm_libc_19_0_0_git::FreeTrie::find_best_fit(size_t)’:
/home/llvm-libc-buildbot/buildbot-worker/libc-x86_64-debian-fullbuild/libc-x86_64-debian-gcc-fullbuild-dbg/llvm-project/libc/src/__support/freetrie.h:185:55: error: suggest parentheses around ‘&&’ within ‘||’ [-Werror=parentheses]
  185 |           deferred_upper_range.min > best_fit->size() &&
      |           ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~
  186 |               "deferred upper subtrie should be outclassed by new best fit");
      |               ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/home/llvm-libc-buildbot/buildbot-worker/libc-x86_64-debian-fullbuild/libc-x86_64-debian-gcc-fullbuild-dbg/llvm-project/libc/src/__support/macros/optimization.h:29:51: note: in definition of macro ‘LIBC_UNLIKELY’
   29 |   LIBC_NAMESPACE::details::expects_bool_condition(x, false)
      |                                                   ^
/home/llvm-libc-buildbot/buildbot-worker/libc-x86_64-debian-fullbuild/libc-x86_64-debian-gcc-fullbuild-dbg/llvm-project/libc/src/__support/freetrie.h:183:7: note: in expansion of macro ‘LIBC_ASSERT’
  183 |       LIBC_ASSERT(
      |       ^~~~~~~~~~~
/home/llvm-libc-buildbot/buildbot-worker/libc-x86_64-debian-fullbuild/libc-x86_64-debian-gcc-fullbuild-dbg/llvm-project/libc/src/__support/freetrie.h:225:70: error: suggest parentheses around ‘&&’ within ‘||’ [-Werror=parentheses]
  225 |                   cur_range.upper().max() < deferred_upper_range.min &&
      |                   ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~
  226 |                       "old deferred upper subtrie should be outclassed by new");
      |                       ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/home/llvm-libc-buildbot/buildbot-worker/libc-x86_64-debian-fullbuild/libc-x86_64-debian-gcc-fullbuild-dbg/llvm-project/libc/src/__support/macros/optimization.h:29:51: note: in definition of macro ‘LIBC_UNLIKELY’
   29 |   LIBC_NAMESPACE::details::expects_bool_condition(x, false)
      |                                                   ^
/home/llvm-libc-buildbot/buildbot-worker/libc-x86_64-debian-fullbuild/libc-x86_64-debian-gcc-fullbuild-dbg/llvm-project/libc/src/__support/freetrie.h:224:7: note: in expansion of macro ‘LIBC_ASSERT’
  224 |       LIBC_ASSERT(!deferred_upper_trie ||
      |       ^~~~~~~~~~~
cc1plus: all warnings being treated as errors
[122/1111] Running unit test libc.test.src.math.fminf_test.__unit__.__NO_FMA_OPT
[==========] Running 5 tests from 1 test suite.
[ RUN      ] LlvmLibcFMinTest.NaN
[       OK ] LlvmLibcFMinTest.NaN (6 us)
[ RUN      ] LlvmLibcFMinTest.InfArg
[       OK ] LlvmLibcFMinTest.InfArg (5 us)

@llvm-ci
Copy link
Collaborator

llvm-ci commented Nov 20, 2024

LLVM Buildbot has detected a new failure on builder libc-riscv64-debian-dbg running on libc-riscv64-debian while building libc at step 4 "annotate".

Full details are available at: https://lab.llvm.org/buildbot/#/builders/188/builds/7051

Here is the relevant piece of the build log for the reference
Step 4 (annotate) failure: 'python ../llvm-zorg/zorg/buildbot/builders/annotated/libc-linux.py ...' (failure)
...
[ RUN      ] LlvmLibcExceptionStatusTest.RaiseAndCrash
[       OK ] LlvmLibcExceptionStatusTest.RaiseAndCrash (6 us)
Ran 1 tests.  PASS: 1  FAIL: 0
[73/1137] Running unit test libc.test.src.fenv.feholdexcept_test.__unit__
[==========] Running 1 test from 1 test suite.
[ RUN      ] LlvmLibcFEnvTest.RaiseAndCrash
[       OK ] LlvmLibcFEnvTest.RaiseAndCrash (6 us)
Ran 1 tests.  PASS: 1  FAIL: 0
[74/1137] Linking CXX executable projects/libc/test/src/__support/libc.test.src.__support.freelist_test.__unit__.__build__
[75/1137] Running unit test libc.test.src.__support.freelist_test.__unit__
FAILED: projects/libc/test/src/__support/CMakeFiles/libc.test.src.__support.freelist_test.__unit__ /home/libc_worker/libc-riscv64-debian/libc-riscv64-debian-dbg/build/projects/libc/test/src/__support/CMakeFiles/libc.test.src.__support.freelist_test.__unit__ 
cd /home/libc_worker/libc-riscv64-debian/libc-riscv64-debian-dbg/build/projects/libc/test/src/__support && /home/libc_worker/libc-riscv64-debian/libc-riscv64-debian-dbg/build/projects/libc/test/src/__support/libc.test.src.__support.freelist_test.__unit__.__build__
[==========] Running 1 test from 1 test suite.
[ RUN      ] LlvmLibcFreeList.FreeList
libc.test.src.__support.freelist_test.__unit__.__build__: /home/libc_worker/libc-riscv64-debian/libc-riscv64-debian-dbg/llvm-project/libc/src/__support/freelist.cpp:17: void __llvm_libc_18_0_0_git::FreeList::push(__llvm_libc_18_0_0_git::FreeList::Node *): Assertion `Block<>::from_usable_space(node)->outer_size() == begin_->block()->outer_size() && "freelist entries must have the same size"' failed.
Aborted
[76/1137] Linking CXX executable projects/libc/test/src/__support/libc.test.src.__support.freestore_test.__unit__.__build__
[77/1137] Linking CXX executable projects/libc/test/src/__support/libc.test.src.__support.freetrie_test.__unit__.__build__
[78/1137] Building CXX object projects/libc/test/src/__support/CMakeFiles/libc.test.src.__support.block_test.__unit__.__build__.dir/block_test.cpp.o
[79/1137] Running unit test libc.test.src.__support.hash_test.__unit__
[==========] Running 4 tests from 1 test suite.
[ RUN      ] LlvmLibcHashTest.SanityCheck
[       OK ] LlvmLibcHashTest.SanityCheck (7 ms)
[ RUN      ] LlvmLibcHashTest.Avalanche
[       OK ] LlvmLibcHashTest.Avalanche (2642 ms)
[ RUN      ] LlvmLibcHashTest.UniformLSB
[       OK ] LlvmLibcHashTest.UniformLSB (1116 ms)
[ RUN      ] LlvmLibcHashTest.UniformMSB
[       OK ] LlvmLibcHashTest.UniformMSB (479 us)
Ran 4 tests.  PASS: 4  FAIL: 0
[80/1137] Running unit test libc.test.src.math.cosf_test.__unit__
[==========] Running 4 tests from 1 test suite.
[ RUN      ] LlvmLibcCosfTest.SpecialNumbers
[       OK ] LlvmLibcCosfTest.SpecialNumbers (14 us)
[ RUN      ] LlvmLibcCosfTest.InFloatRange
[       OK ] LlvmLibcCosfTest.InFloatRange (3581 ms)
[ RUN      ] LlvmLibcCosfTest.SpecificBitPatterns
[       OK ] LlvmLibcCosfTest.SpecificBitPatterns (6 ms)
[ RUN      ] LlvmLibcCosfTest.SDCOMP_26094
[       OK ] LlvmLibcCosfTest.SDCOMP_26094 (144 us)
Ran 4 tests.  PASS: 4  FAIL: 0
ninja: build stopped: subcommand failed.
['ninja', 'libc-unit-tests'] exited with return code 1.
The build step threw an exception...
Traceback (most recent call last):
  File "/home/libc_worker/libc-riscv64-debian/libc-riscv64-debian-dbg/build/../llvm-zorg/zorg/buildbot/builders/annotated/libc-linux.py", line 162, in step
    yield
  File "/home/libc_worker/libc-riscv64-debian/libc-riscv64-debian-dbg/build/../llvm-zorg/zorg/buildbot/builders/annotated/libc-linux.py", line 135, in main
    run_command(['ninja', 'libc-unit-tests'])
Step 7 (libc-unit-tests) failure: libc-unit-tests (failure)
...
[ RUN      ] LlvmLibcExceptionStatusTest.RaiseAndCrash
[       OK ] LlvmLibcExceptionStatusTest.RaiseAndCrash (6 us)
Ran 1 tests.  PASS: 1  FAIL: 0
[73/1137] Running unit test libc.test.src.fenv.feholdexcept_test.__unit__
[==========] Running 1 test from 1 test suite.
[ RUN      ] LlvmLibcFEnvTest.RaiseAndCrash
[       OK ] LlvmLibcFEnvTest.RaiseAndCrash (6 us)
Ran 1 tests.  PASS: 1  FAIL: 0
[74/1137] Linking CXX executable projects/libc/test/src/__support/libc.test.src.__support.freelist_test.__unit__.__build__
[75/1137] Running unit test libc.test.src.__support.freelist_test.__unit__
FAILED: projects/libc/test/src/__support/CMakeFiles/libc.test.src.__support.freelist_test.__unit__ /home/libc_worker/libc-riscv64-debian/libc-riscv64-debian-dbg/build/projects/libc/test/src/__support/CMakeFiles/libc.test.src.__support.freelist_test.__unit__ 
cd /home/libc_worker/libc-riscv64-debian/libc-riscv64-debian-dbg/build/projects/libc/test/src/__support && /home/libc_worker/libc-riscv64-debian/libc-riscv64-debian-dbg/build/projects/libc/test/src/__support/libc.test.src.__support.freelist_test.__unit__.__build__
[==========] Running 1 test from 1 test suite.
[ RUN      ] LlvmLibcFreeList.FreeList
libc.test.src.__support.freelist_test.__unit__.__build__: /home/libc_worker/libc-riscv64-debian/libc-riscv64-debian-dbg/llvm-project/libc/src/__support/freelist.cpp:17: void __llvm_libc_18_0_0_git::FreeList::push(__llvm_libc_18_0_0_git::FreeList::Node *): Assertion `Block<>::from_usable_space(node)->outer_size() == begin_->block()->outer_size() && "freelist entries must have the same size"' failed.
Aborted
[76/1137] Linking CXX executable projects/libc/test/src/__support/libc.test.src.__support.freestore_test.__unit__.__build__
[77/1137] Linking CXX executable projects/libc/test/src/__support/libc.test.src.__support.freetrie_test.__unit__.__build__
[78/1137] Building CXX object projects/libc/test/src/__support/CMakeFiles/libc.test.src.__support.block_test.__unit__.__build__.dir/block_test.cpp.o
[79/1137] Running unit test libc.test.src.__support.hash_test.__unit__
[==========] Running 4 tests from 1 test suite.
[ RUN      ] LlvmLibcHashTest.SanityCheck
[       OK ] LlvmLibcHashTest.SanityCheck (7 ms)
[ RUN      ] LlvmLibcHashTest.Avalanche
[       OK ] LlvmLibcHashTest.Avalanche (2642 ms)
[ RUN      ] LlvmLibcHashTest.UniformLSB
[       OK ] LlvmLibcHashTest.UniformLSB (1116 ms)
[ RUN      ] LlvmLibcHashTest.UniformMSB
[       OK ] LlvmLibcHashTest.UniformMSB (479 us)
Ran 4 tests.  PASS: 4  FAIL: 0
[80/1137] Running unit test libc.test.src.math.cosf_test.__unit__
[==========] Running 4 tests from 1 test suite.
[ RUN      ] LlvmLibcCosfTest.SpecialNumbers
[       OK ] LlvmLibcCosfTest.SpecialNumbers (14 us)
[ RUN      ] LlvmLibcCosfTest.InFloatRange
[       OK ] LlvmLibcCosfTest.InFloatRange (3581 ms)
[ RUN      ] LlvmLibcCosfTest.SpecificBitPatterns
[       OK ] LlvmLibcCosfTest.SpecificBitPatterns (6 ms)
[ RUN      ] LlvmLibcCosfTest.SDCOMP_26094
[       OK ] LlvmLibcCosfTest.SDCOMP_26094 (144 us)
Ran 4 tests.  PASS: 4  FAIL: 0
ninja: build stopped: subcommand failed.
['ninja', 'libc-unit-tests'] exited with return code 1.
The build step threw an exception...
Traceback (most recent call last):
  File "/home/libc_worker/libc-riscv64-debian/libc-riscv64-debian-dbg/build/../llvm-zorg/zorg/buildbot/builders/annotated/libc-linux.py", line 162, in step
    yield
  File "/home/libc_worker/libc-riscv64-debian/libc-riscv64-debian-dbg/build/../llvm-zorg/zorg/buildbot/builders/annotated/libc-linux.py", line 135, in main
    run_command(['ninja', 'libc-unit-tests'])

@llvm-ci
Copy link
Collaborator

llvm-ci commented Nov 20, 2024

LLVM Buildbot has detected a new failure on builder libc-riscv32-qemu-yocto-fullbuild-dbg running on rv32gc-qemu-system while building libc at step 4 "annotate".

Full details are available at: https://lab.llvm.org/buildbot/#/builders/196/builds/1310

Here is the relevant piece of the build log for the reference
Step 4 (annotate) failure: 'python ../llvm-zorg/zorg/buildbot/builders/annotated/libc-linux.py ...' (failure)
...
[ RUN      ] LlvmLibcStrToIntegerTest.Base16PrefixManualSelect
[       OK ] LlvmLibcStrToIntegerTest.Base16PrefixManualSelect (660 us)
[ RUN      ] LlvmLibcStrToIntegerTest.Base8PrefixAutoSelect
[       OK ] LlvmLibcStrToIntegerTest.Base8PrefixAutoSelect (488 us)
[ RUN      ] LlvmLibcStrToIntegerTest.Base8PrefixManualSelect
[       OK ] LlvmLibcStrToIntegerTest.Base8PrefixManualSelect (411 us)
[ RUN      ] LlvmLibcStrToIntegerTest.CombinedTests
[       OK ] LlvmLibcStrToIntegerTest.CombinedTests (238 us)
Ran 8 tests.  PASS: 8  FAIL: 0
[36/940] Running unit test libc.test.src.__support.freestore_test.__unit__
FAILED: projects/libc/test/src/__support/CMakeFiles/libc.test.src.__support.freestore_test.__unit__ /home/libcrv32buildbot/bbroot/libc-riscv32-qemu-yocto-fullbuild-dbg/build/projects/libc/test/src/__support/CMakeFiles/libc.test.src.__support.freestore_test.__unit__ 
cd /home/libcrv32buildbot/bbroot/libc-riscv32-qemu-yocto-fullbuild-dbg/build/projects/libc/test/src/__support && /home/libcrv32buildbot/cross.sh /home/libcrv32buildbot/bbroot/libc-riscv32-qemu-yocto-fullbuild-dbg/build/projects/libc/test/src/__support/libc.test.src.__support.freestore_test.__unit__.__build__
WARNING: libc/test/src/__support/libc.test.src.__support.freelist_test.__unit__.__build__ failed verification -- update discarded (will try again).
sh: line 1: /timer.31798: Permission denied
[==========] Running 3 tests from 1 test suite.
[ RUN      ] LlvmLibcFreeStore.TooSmall
[       OK ] LlvmLibcFreeStore.TooSmall (2 ms)
[ RUN      ] LlvmLibcFreeStore.RemoveBestFit
/home/libcrv32buildbot/bbroot/libc-riscv32-qemu-yocto-fullbuild-dbg/llvm-project/libc/test/src/__support/freestore_test.cpp:53: FAILURE
          Expected: largest_small->inner_size()
          Which is: 20
To be greater than: smallest->inner_size()
          Which is: 20
[  FAILED  ] LlvmLibcFreeStore.RemoveBestFit
[ RUN      ] LlvmLibcFreeStore.Remove
[       OK ] LlvmLibcFreeStore.Remove (785 us)
Ran 3 tests.  PASS: 2  FAIL: 1
[37/940] Running unit test libc.test.src.__support.integer_literals_test.__unit__
WARNING: libc/test/src/__support/libc.test.src.__support.freelist_test.__unit__.__build__ failed verification -- update discarded (will try again).
sh: line 1: /timer.31795: Permission denied
[==========] Running 8 tests from 1 test suite.
[ RUN      ] LlvmLibcIntegerLiteralTest.u8
[       OK ] LlvmLibcIntegerLiteralTest.u8 (514 us)
[ RUN      ] LlvmLibcIntegerLiteralTest.u16
[       OK ] LlvmLibcIntegerLiteralTest.u16 (325 us)
[ RUN      ] LlvmLibcIntegerLiteralTest.u32
[       OK ] LlvmLibcIntegerLiteralTest.u32 (399 us)
[ RUN      ] LlvmLibcIntegerLiteralTest.u64
[       OK ] LlvmLibcIntegerLiteralTest.u64 (656 us)
[ RUN      ] LlvmLibcIntegerLiteralTest.u128
[       OK ] LlvmLibcIntegerLiteralTest.u128 (4 ms)
[ RUN      ] LlvmLibcIntegerLiteralTest.u256
[       OK ] LlvmLibcIntegerLiteralTest.u256 (7 ms)
[ RUN      ] LlvmLibcIntegerLiteralTest.parse_bigint
[       OK ] LlvmLibcIntegerLiteralTest.parse_bigint (2 ms)
[ RUN      ] LlvmLibcIntegerLiteralTest.parse_bigint_invalid
[       OK ] LlvmLibcIntegerLiteralTest.parse_bigint_invalid (166 us)
Ran 8 tests.  PASS: 8  FAIL: 0
[38/940] Running unit test libc.test.src.__support.integer_to_string_test.__unit__
Step 8 (libc-unit-tests) failure: libc-unit-tests (failure)
...
[ RUN      ] LlvmLibcStrToIntegerTest.Base16PrefixManualSelect
[       OK ] LlvmLibcStrToIntegerTest.Base16PrefixManualSelect (660 us)
[ RUN      ] LlvmLibcStrToIntegerTest.Base8PrefixAutoSelect
[       OK ] LlvmLibcStrToIntegerTest.Base8PrefixAutoSelect (488 us)
[ RUN      ] LlvmLibcStrToIntegerTest.Base8PrefixManualSelect
[       OK ] LlvmLibcStrToIntegerTest.Base8PrefixManualSelect (411 us)
[ RUN      ] LlvmLibcStrToIntegerTest.CombinedTests
[       OK ] LlvmLibcStrToIntegerTest.CombinedTests (238 us)
Ran 8 tests.  PASS: 8  FAIL: 0
[36/940] Running unit test libc.test.src.__support.freestore_test.__unit__
FAILED: projects/libc/test/src/__support/CMakeFiles/libc.test.src.__support.freestore_test.__unit__ /home/libcrv32buildbot/bbroot/libc-riscv32-qemu-yocto-fullbuild-dbg/build/projects/libc/test/src/__support/CMakeFiles/libc.test.src.__support.freestore_test.__unit__ 
cd /home/libcrv32buildbot/bbroot/libc-riscv32-qemu-yocto-fullbuild-dbg/build/projects/libc/test/src/__support && /home/libcrv32buildbot/cross.sh /home/libcrv32buildbot/bbroot/libc-riscv32-qemu-yocto-fullbuild-dbg/build/projects/libc/test/src/__support/libc.test.src.__support.freestore_test.__unit__.__build__
WARNING: libc/test/src/__support/libc.test.src.__support.freelist_test.__unit__.__build__ failed verification -- update discarded (will try again).
sh: line 1: /timer.31798: Permission denied
[==========] Running 3 tests from 1 test suite.
[ RUN      ] LlvmLibcFreeStore.TooSmall
[       OK ] LlvmLibcFreeStore.TooSmall (2 ms)
[ RUN      ] LlvmLibcFreeStore.RemoveBestFit
/home/libcrv32buildbot/bbroot/libc-riscv32-qemu-yocto-fullbuild-dbg/llvm-project/libc/test/src/__support/freestore_test.cpp:53: FAILURE
          Expected: largest_small->inner_size()
          Which is: 20
To be greater than: smallest->inner_size()
          Which is: 20
[  FAILED  ] LlvmLibcFreeStore.RemoveBestFit
[ RUN      ] LlvmLibcFreeStore.Remove
[       OK ] LlvmLibcFreeStore.Remove (785 us)
Ran 3 tests.  PASS: 2  FAIL: 1
[37/940] Running unit test libc.test.src.__support.integer_literals_test.__unit__
WARNING: libc/test/src/__support/libc.test.src.__support.freelist_test.__unit__.__build__ failed verification -- update discarded (will try again).
sh: line 1: /timer.31795: Permission denied
[==========] Running 8 tests from 1 test suite.
[ RUN      ] LlvmLibcIntegerLiteralTest.u8
[       OK ] LlvmLibcIntegerLiteralTest.u8 (514 us)
[ RUN      ] LlvmLibcIntegerLiteralTest.u16
[       OK ] LlvmLibcIntegerLiteralTest.u16 (325 us)
[ RUN      ] LlvmLibcIntegerLiteralTest.u32
[       OK ] LlvmLibcIntegerLiteralTest.u32 (399 us)
[ RUN      ] LlvmLibcIntegerLiteralTest.u64
[       OK ] LlvmLibcIntegerLiteralTest.u64 (656 us)
[ RUN      ] LlvmLibcIntegerLiteralTest.u128
[       OK ] LlvmLibcIntegerLiteralTest.u128 (4 ms)
[ RUN      ] LlvmLibcIntegerLiteralTest.u256
[       OK ] LlvmLibcIntegerLiteralTest.u256 (7 ms)
[ RUN      ] LlvmLibcIntegerLiteralTest.parse_bigint
[       OK ] LlvmLibcIntegerLiteralTest.parse_bigint (2 ms)
[ RUN      ] LlvmLibcIntegerLiteralTest.parse_bigint_invalid
[       OK ] LlvmLibcIntegerLiteralTest.parse_bigint_invalid (166 us)
Ran 8 tests.  PASS: 8  FAIL: 0
[38/940] Running unit test libc.test.src.__support.integer_to_string_test.__unit__

@llvm-ci
Copy link
Collaborator

llvm-ci commented Nov 20, 2024

LLVM Buildbot has detected a new failure on builder libc-riscv64-debian-fullbuild-dbg running on libc-riscv64-debian while building libc at step 4 "annotate".

Full details are available at: https://lab.llvm.org/buildbot/#/builders/183/builds/6530

Here is the relevant piece of the build log for the reference
Step 4 (annotate) failure: 'python ../llvm-zorg/zorg/buildbot/builders/annotated/libc-linux.py ...' (failure)
...
Ran 5 tests.  PASS: 5  FAIL: 0
[45/1028] Linking CXX executable projects/libc/test/src/__support/libc.test.src.__support.freelist_test.__unit__.__build__
[46/1028] Running unit test libc.test.src.complex.creal_test.__unit__
[==========] Running 2 tests from 1 test suite.
[ RUN      ] LlvmLibcCRealTest.SpecialNumbers
[       OK ] LlvmLibcCRealTest.SpecialNumbers (20 us)
[ RUN      ] LlvmLibcCRealTest.RoundedNumbers
[       OK ] LlvmLibcCRealTest.RoundedNumbers (12 us)
Ran 2 tests.  PASS: 2  FAIL: 0
[47/1028] Running unit test libc.test.src.__support.freelist_test.__unit__
FAILED: projects/libc/test/src/__support/CMakeFiles/libc.test.src.__support.freelist_test.__unit__ /home/libc_worker/libc-riscv64-debian/libc-riscv64-debian-fullbuild-dbg/build/projects/libc/test/src/__support/CMakeFiles/libc.test.src.__support.freelist_test.__unit__ 
cd /home/libc_worker/libc-riscv64-debian/libc-riscv64-debian-fullbuild-dbg/build/projects/libc/test/src/__support && /home/libc_worker/libc-riscv64-debian/libc-riscv64-debian-fullbuild-dbg/build/projects/libc/test/src/__support/libc.test.src.__support.freelist_test.__unit__.__build__
[==========] Running 1 test from 1 test suite.
[ RUN      ] LlvmLibcFreeList.FreeList
/home/libc_worker/libc-riscv64-debian/libc-riscv64-debian-fullbuild-dbg/llvm-project/libc/src/__support/freelist.cpp:17: Assertion failed: 'Block<>::from_usable_space(node)->outer_size() == begin_->block()->outer_size() && "freelist entries must have the same size"' in function: 'void __llvm_libc_18_0_0_git::FreeList::push(__llvm_libc_18_0_0_git::FreeList::Node *)'
[48/1028] Running unit test libc.test.src.__support.threads.linux.raw_mutex_test.__unit__
[==========] Running 3 tests from 1 test suite.
[ RUN      ] LlvmLibcSupportThreadsRawMutexTest.SmokeTest
[       OK ] LlvmLibcSupportThreadsRawMutexTest.SmokeTest (7 us)
[ RUN      ] LlvmLibcSupportThreadsRawMutexTest.Timeout
[       OK ] LlvmLibcSupportThreadsRawMutexTest.Timeout (263 us)
[ RUN      ] LlvmLibcSupportThreadsRawMutexTest.PSharedLock
[       OK ] LlvmLibcSupportThreadsRawMutexTest.PSharedLock (6 ms)
Ran 3 tests.  PASS: 3  FAIL: 0
[49/1028] Running unit test libc.test.src.complex.crealf_test.__unit__
[==========] Running 2 tests from 1 test suite.
[ RUN      ] LlvmLibcCRealTest.SpecialNumbers
[       OK ] LlvmLibcCRealTest.SpecialNumbers (18 us)
[ RUN      ] LlvmLibcCRealTest.RoundedNumbers
[       OK ] LlvmLibcCRealTest.RoundedNumbers (13 us)
Ran 2 tests.  PASS: 2  FAIL: 0
[50/1028] Linking CXX executable projects/libc/test/src/__support/libc.test.src.__support.freestore_test.__unit__.__build__
[51/1028] Building CXX object projects/libc/test/src/__support/CMakeFiles/libc.test.src.__support.block_test.__unit__.__build__.dir/block_test.cpp.o
[52/1028] Running unit test libc.test.src.__support.hash_test.__unit__
[==========] Running 4 tests from 1 test suite.
[ RUN      ] LlvmLibcHashTest.SanityCheck
[       OK ] LlvmLibcHashTest.SanityCheck (7 ms)
[ RUN      ] LlvmLibcHashTest.Avalanche
[       OK ] LlvmLibcHashTest.Avalanche (2690 ms)
[ RUN      ] LlvmLibcHashTest.UniformLSB
[       OK ] LlvmLibcHashTest.UniformLSB (1157 ms)
[ RUN      ] LlvmLibcHashTest.UniformMSB
[       OK ] LlvmLibcHashTest.UniformMSB (532 us)
Ran 4 tests.  PASS: 4  FAIL: 0
ninja: build stopped: subcommand failed.
['ninja', 'libc-unit-tests'] exited with return code 1.
The build step threw an exception...
Traceback (most recent call last):
  File "/home/libc_worker/libc-riscv64-debian/libc-riscv64-debian-fullbuild-dbg/build/../llvm-zorg/zorg/buildbot/builders/annotated/libc-linux.py", line 162, in step
Step 8 (libc-unit-tests) failure: libc-unit-tests (failure)
...
Ran 5 tests.  PASS: 5  FAIL: 0
[45/1028] Linking CXX executable projects/libc/test/src/__support/libc.test.src.__support.freelist_test.__unit__.__build__
[46/1028] Running unit test libc.test.src.complex.creal_test.__unit__
[==========] Running 2 tests from 1 test suite.
[ RUN      ] LlvmLibcCRealTest.SpecialNumbers
[       OK ] LlvmLibcCRealTest.SpecialNumbers (20 us)
[ RUN      ] LlvmLibcCRealTest.RoundedNumbers
[       OK ] LlvmLibcCRealTest.RoundedNumbers (12 us)
Ran 2 tests.  PASS: 2  FAIL: 0
[47/1028] Running unit test libc.test.src.__support.freelist_test.__unit__
FAILED: projects/libc/test/src/__support/CMakeFiles/libc.test.src.__support.freelist_test.__unit__ /home/libc_worker/libc-riscv64-debian/libc-riscv64-debian-fullbuild-dbg/build/projects/libc/test/src/__support/CMakeFiles/libc.test.src.__support.freelist_test.__unit__ 
cd /home/libc_worker/libc-riscv64-debian/libc-riscv64-debian-fullbuild-dbg/build/projects/libc/test/src/__support && /home/libc_worker/libc-riscv64-debian/libc-riscv64-debian-fullbuild-dbg/build/projects/libc/test/src/__support/libc.test.src.__support.freelist_test.__unit__.__build__
[==========] Running 1 test from 1 test suite.
[ RUN      ] LlvmLibcFreeList.FreeList
/home/libc_worker/libc-riscv64-debian/libc-riscv64-debian-fullbuild-dbg/llvm-project/libc/src/__support/freelist.cpp:17: Assertion failed: 'Block<>::from_usable_space(node)->outer_size() == begin_->block()->outer_size() && "freelist entries must have the same size"' in function: 'void __llvm_libc_18_0_0_git::FreeList::push(__llvm_libc_18_0_0_git::FreeList::Node *)'
[48/1028] Running unit test libc.test.src.__support.threads.linux.raw_mutex_test.__unit__
[==========] Running 3 tests from 1 test suite.
[ RUN      ] LlvmLibcSupportThreadsRawMutexTest.SmokeTest
[       OK ] LlvmLibcSupportThreadsRawMutexTest.SmokeTest (7 us)
[ RUN      ] LlvmLibcSupportThreadsRawMutexTest.Timeout
[       OK ] LlvmLibcSupportThreadsRawMutexTest.Timeout (263 us)
[ RUN      ] LlvmLibcSupportThreadsRawMutexTest.PSharedLock
[       OK ] LlvmLibcSupportThreadsRawMutexTest.PSharedLock (6 ms)
Ran 3 tests.  PASS: 3  FAIL: 0
[49/1028] Running unit test libc.test.src.complex.crealf_test.__unit__
[==========] Running 2 tests from 1 test suite.
[ RUN      ] LlvmLibcCRealTest.SpecialNumbers
[       OK ] LlvmLibcCRealTest.SpecialNumbers (18 us)
[ RUN      ] LlvmLibcCRealTest.RoundedNumbers
[       OK ] LlvmLibcCRealTest.RoundedNumbers (13 us)
Ran 2 tests.  PASS: 2  FAIL: 0
[50/1028] Linking CXX executable projects/libc/test/src/__support/libc.test.src.__support.freestore_test.__unit__.__build__
[51/1028] Building CXX object projects/libc/test/src/__support/CMakeFiles/libc.test.src.__support.block_test.__unit__.__build__.dir/block_test.cpp.o
[52/1028] Running unit test libc.test.src.__support.hash_test.__unit__
[==========] Running 4 tests from 1 test suite.
[ RUN      ] LlvmLibcHashTest.SanityCheck
[       OK ] LlvmLibcHashTest.SanityCheck (7 ms)
[ RUN      ] LlvmLibcHashTest.Avalanche
[       OK ] LlvmLibcHashTest.Avalanche (2690 ms)
[ RUN      ] LlvmLibcHashTest.UniformLSB
[       OK ] LlvmLibcHashTest.UniformLSB (1157 ms)
[ RUN      ] LlvmLibcHashTest.UniformMSB
[       OK ] LlvmLibcHashTest.UniformMSB (532 us)
Ran 4 tests.  PASS: 4  FAIL: 0
ninja: build stopped: subcommand failed.
['ninja', 'libc-unit-tests'] exited with return code 1.
The build step threw an exception...
Traceback (most recent call last):
  File "/home/libc_worker/libc-riscv64-debian/libc-riscv64-debian-fullbuild-dbg/build/../llvm-zorg/zorg/buildbot/builders/annotated/libc-linux.py", line 162, in step

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants