chriskohlhoff
Repos
27
Followers
889

Events

issue comment
Segfault when exception thrown from within stackful coroutine

I've made a tentative change in https://github.com/chriskohlhoff/asio/commit/96e1a95449664d426afeacd010454b9750a34de4 to allow the coroutine to run to completion if the user-supplied function has itself completed. This should eliminate the forced_unwind in that case.

Created at 1 month ago

Allow a terminal-state spawned thread to run to completion when destroyed.

Re-throw exception from top-level spawn()-ed function.

Created at 1 month ago
issue comment
Feature request: Type-erased handler wrapper

That legacy non-completion-token overload of spawn wraps the executor in a strand, so cannot work with any_completion_executor. You'll need to use the completion-token overload for compatibility with any_completion_executor.

Created at 1 month ago
issue comment
Segfault when exception thrown from within stackful coroutine

@AsonWon can you please paste the output of you test program above when you run it outside of visual studio, at the command prompt.

On Wed, Aug 24, 2022, at 9:45 PM, AsonWon wrote:

@chriskohlhoff https://github.com/chriskohlhoff According to my test results, the forced_unwind exception being thrown by boost::asio is not being caught inside the library, the caught code may not be executed inside the library. I use boost_1_80_0-msvc-14.2-64.

— Reply to this email directly, view it on GitHub https://github.com/chriskohlhoff/asio/issues/1110#issuecomment-1225606862, or unsubscribe https://github.com/notifications/unsubscribe-auth/AADQ5STBJ5S7QFNAYTBLN33V2YDL5ANCNFSM5667OL7Q. You are receiving this because you were mentioned.Message ID: @.***>

Created at 1 month ago
issue comment
Segfault when exception thrown from within stackful coroutine

Yep: https://github.com/chriskohlhoff/asio/issues/1111#issuecomment-1223584534

Instead of detached pass [](std::exception_ptr e){ if (e) std::rethrow_exception(e); }

Created at 1 month ago
issue comment
Linking to Boost.Coroutine still needed in Boost 1.80 when using asio::spawn and asio::yield_context

In case it matters to you (I'm just thinking based on #1110 that it might), please note that this will do something slightly different with respect to exceptions that escape from your spawned function, because this overload passes the exception_ptr to the completion handler, and detached just swallows everything.

Created at 1 month ago
issue comment
Segfault when exception thrown from within stackful coroutine

@AsonWon That's the debugger telling you an exception is being thrown. Is it being caught inside the library? It should be. If so, that's not a bug.

Created at 1 month ago
issue comment
Linking to Boost.Coroutine still needed in Boost 1.80 when using asio::spawn and asio::yield_context

That's because the overloads that take boost::coroutines::attributes are still there for backwards compatibility. Define BOOST_ASIO_DISABLE_BOOST_COROUTINE to disable them completely.

Created at 1 month ago
issue comment
Segfault when exception thrown from within stackful coroutine

@ecorm Can you please try with the changes in this commit https://github.com/chriskohlhoff/asio/commit/13045b6017e13b5884b4a95b6a80f485b42f1edc

@AsonWon I cannot reproduce any problem with your test program. Are you getting an unhandled exception resulting in a crash? Or are you simply observing that there is a forced_unwind exception being thrown and handled within the spawn implementation (which is expected behaviour)?

Created at 1 month ago
create branch
chriskohlhoff create branch spawn-exceptions-fix
Created at 1 month ago
create branch
chriskohlhoff create branch citest-master
Created at 1 month ago
issue comment
Feature request: Type-erased handler wrapper

I pushed an updated branch with some changes to ensure that the associated_executor specialisation won't throw (and consequently std::terminate) if constructing the any_completion_executor needs to allocate but allocation fails.

Created at 1 month ago

Regenerate platform macros documentation.

Revision history.

asio version 1.24.0 released

Add any_completion_handler<>.

Forward get_associated_executor through to type-erased handler.

Add missing context query to use_future's executor.

Remove rvalue reference qualifier from any_competion_handler::operator().

Add any_completion_executor.

Add definition for any_completion_handler function table.

Add additional constructors, swap, assignment, and comparisons.

Get the associated allocator from the target handler.

Add missing file.

Add nothrow constructor overloads to execution::any_executor<>.

Add nothrow constructor overloads to any_io_executor.

Add nothrow constructor overloads to any_completion_executor.

Use any_completion_executor's nothrow constructors.

Created at 1 month ago

Regenerate platform macros documentation.

Revision history.

asio version 1.24.0 released

Created at 1 month ago
create tag
chriskohlhoff create tag asio-1-24-0
Created at 1 month ago
pull request opened
Asio release notes for 1.80
Created at 1 month ago

Asio release notes for 1.80

Created at 1 month ago
issue comment
Feature request: Type-erased handler wrapper

So I did. Fixed.

Created at 1 month ago

Add missing file.

Created at 1 month ago
issue comment
Feature request: Type-erased handler wrapper

For that matter, why must it be any_io_executor that type-erases the executor? Why impose that executors for handlers have an I/O context?

May I suggest that a new any_completion_executor type alias be introduced for use with any_completion_handler?

You're correct, and this is something i've been planning too, so I've added it to the branch. (However, before merging this I want to investigate relaxing the requirements on a completion executor some more, and that requires some further thought.)

I have also added the other things you mentioned (except cancellation which was already there).

Created at 1 month ago

Add any_completion_executor.

Add definition for any_completion_handler function table.

Add additional constructors, swap, assignment, and comparisons.

Get the associated allocator from the target handler.

Created at 1 month ago

Add missing context query to use_future's executor.

Remove rvalue reference qualifier from any_competion_handler::operator().

Created at 1 month ago
issue comment
Feature request: Type-erased handler wrapper

bind doesn't like the rvalue reference qualifier on operator(). I've removed this and pushed an update to the branch (with some other fixes, including the use_future problem).

On the requirement for multi-shot handlers, a while back I extended async_result to support reference qualification on completion signatures for this exact reason, however I haven't really done anything with them yet. For example:

  • void(error_code) -> current behaviour: one-shot, calling consumes the completion handler
  • void(error_code) & -> multi-shot, calling does not consume handler, implies copyability
  • void(error_code) && -> synonym for one-shot

any_completion_handler could be made to support this, and automatically apply move-only or copyable semantics accordingly. (Note that dispatching on to the correct handler would still be the responsibility of the caller of the completion handler, as it is now.)

Created at 1 month ago

Forward get_associated_executor through to type-erased handler.

Add missing context query to use_future's executor.

Remove rvalue reference qualifier from any_competion_handler::operator().

Created at 1 month ago

Make standard library feature macros available.

Add pkg-config support.

Revision history.

asio version 1.23.0 released

Disable index_sequence emulation when variadic templates are unavailable.

Avoid copying async operation object in await_transform.

Change async_compose example to use return type compatible with new async_result form.

Fix detection of aligned_alloc for Apple platforms.

Remove faulty assertions from experimental::coro implementation.

Defend against Qt macros when using Intel C++.

Destroy spawned thread immediately if it completes within handler invocation.

Store reference to basic_yield_context in handler.

Improves performance by not copying the executor into the handler.

Boostify the quick reference.

Recreate the select_reactor's interrupter on a user-supplied thread, when using IOCP on Windows.

Change MSVC version used for system_error workaround.

More recent runtime redistributables appear to have fixed the issue.

Remove hardcoded path.

Add experimental::co_composed.

Created at 1 month ago
issue comment
Feature request: Type-erased handler wrapper

I hacked together a prototype on this branch:

https://github.com/chriskohlhoff/asio/tree/any-completion-handler

Example found here:

https://github.com/chriskohlhoff/asio/tree/any-completion-handler/asio/src/examples/cpp20/type_erasure

Created at 1 month ago
create branch
chriskohlhoff create branch any-completion-handler
Created at 1 month ago

Disable index_sequence emulation when variadic templates are unavailable.

Avoid copying async operation object in await_transform.

Change async_compose example to use return type compatible with new async_result form.

Fix detection of aligned_alloc for Apple platforms.

Remove faulty assertions from experimental::coro implementation.

Defend against Qt macros when using Intel C++.

Destroy spawned thread immediately if it completes within handler invocation.

Store reference to basic_yield_context in handler.

Improves performance by not copying the executor into the handler.

Add use_promise and use_promise_t to the quick reference.

Recreate the select_reactor's interrupter on a user-supplied thread, when using IOCP on Windows.

Regenerate platform macros documentation.

Update revision history.

Version bump.

Merge asio 1.24.0 from 'develop'.

Created at 1 month ago

Regenerate platform macros documentation.

Update revision history.

Version bump.

Created at 1 month ago
issue comment
unhandled exception in select_reactor thread leads to process termination

It will.

Created at 1 month ago