[libcxx-commits] [PATCH] D103196: [libcxx][nfc] Fix the ASAN bots: update expected.pass.cpp.

Zoe Carver via Phabricator via libcxx-commits libcxx-commits at lists.llvm.org
Wed May 26 13:02:49 PDT 2021


zoecarver added a comment.

In D103196#2782994 <https://reviews.llvm.org/D103196#2782994>, @ldionne wrote:

> I have an intuition that this is related to https://bugs.llvm.org/show_bug.cgi?id=50369, which might not be fixed in reality. WDYT?

@ldionne I think it's unlikely that this has anything to do with `shared_ptr`. Below is a minimal reproducer that causes the same problem with the sanitizers. As you can see, there's no reference to `shared_ptr`, or any pointer. I think the new/delete that the bots are referencing is the new/delete that is used to create and deallocate the coroutine state (or maybe it's the promise... that might actually explain why it's trying to use the same memory).

  // ADDITIONAL_COMPILE_FLAGS: -g -fsanitize=address
  
  #include <experimental/coroutine>
  #include <cassert>
  #include <memory>
  
  #include "test_macros.h"
  
  using namespace std::experimental;
  
  int x;
  
  struct tag { char data[8]; }; // `tag` can be any type. It could be empty, or an int, or anything. 
  
  struct expected {
    char data; // No issues if this member isn't here.
  
    expected(tag) : data() {}
  
    struct promise_type {
      tag get_return_object() { return {}; } // No issues if we return an `expected` instead. 
      suspend_never initial_suspend() { return {}; }
      suspend_never final_suspend() noexcept { return {}; }
      tag return_value(tag) { return tag{}; }
      void unhandled_exception() {}
    };
  };
  
  expected f1() {
    co_return {};
  }
  
  int main(int, char**) {
    auto c1 = f1();
    (void)c1;
  
    return 0;
  }


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D103196



More information about the libcxx-commits mailing list