NVIDIA / stdexec

`std::execution`, the proposed C++ framework for asynchronous and parallel programming.
Apache License 2.0
1.56k stars 159 forks source link

Help in locating circle codegen issue #860

Closed seanbaxter closed 1 year ago

seanbaxter commented 1 year ago

Circle compiles all the stdexec tests, but there's a codegen issue affecting the test_any_sender.cpp tests, which fail at runtime. I started a repro file, which is linked below, but it's still way too complex. Would it be possible to cut this repro down, ideally to a self-contained file, so I can see what the issue is? There's so much manual vtable work that I don't understand. https://github.com/seanbaxter/stdexec/blob/circle/circle.md#issues

maikel commented 1 year ago

Hi,

I have it on my personal TODO list to simplify any_sender_of and remove all unneeded CPOs. The __connect pointer, which you ask for is initialized in the following overload of tag_invoke

        template <sender_to<__receiver_ref_t> _Sender>
        friend const __vtable*
          tag_invoke(__create_vtable_t, __mtype<__vtable>, __mtype<_Sender>) noexcept {
          static const __vtable __vtable_{
            {*__create_vtable(__mtype<__query_vtable<_SenderQueries>>{}, __mtype<_Sender>{})},
            [](void* __object_pointer, __receiver_ref_t __receiver) -> __unique_operation_storage {
              _Sender& __sender = *static_cast<_Sender*>(__object_pointer);
              using __op_state_t = connect_result_t<_Sender, __receiver_ref_t>;
              return __unique_operation_storage{
                std::in_place_type<__op_state_t>, __conv{[&] {
                  return connect((_Sender&&) __sender, (__receiver_ref_t&&) __receiver);
                }}};
            }};
          return &__vtable_;
        }

The __cretae_vtable_t CPO is used to fill all the vtables for the type erasure. The lambda that you see there is used to initialize the __connect pointer. Does this help somehow? If not, I will try to simplify the code next week.

seanbaxter commented 1 year ago

I would really benefit from a cut down repro file. It's very hard to diagnose codegen bugs otherwise.

maikel commented 1 year ago

Sorry, but I can not cut you down a reproducer for this, because I cannot reproduce the error locally. I can try to simplify the implementation.

seanbaxter commented 1 year ago

I found and patched the issue. It was improper counting of empty base classes during aggregate initialization for constant/static initializers. Now stdexec passes with 100%.