Skip to content

Fix asio::co_composed crash on MSVC#2

Merged
annihilatorq merged 5 commits intomainfrom
co_composed-msvc-fix
Mar 9, 2026
Merged

Fix asio::co_composed crash on MSVC#2
annihilatorq merged 5 commits intomainfrom
co_composed-msvc-fix

Conversation

@annihilatorq
Copy link
Member

see: chriskohlhoff/asio#1724

this pr fixes a bug related to asio by using the alignment capability built into asio::co_composed_future with a custom allocator bound to the completion token

the union inside asio::co_composed_future will take alignof(allocator_type), and allocator_type will be the allocator associated with the completion token. therefore, all we need to do is create a simple allocator with alignas(16), after which the compiler will automatically align asio::co_composed_future::block by 16 bytes, and the SSE movaps instruction, which was incorrectly emitted by the MSVC, will be able to be executed correctly without triggering STATUS_ACCESS_VIOLATION (GP fault)

@annihilatorq
Copy link
Member Author

in that case, it would be good to extend the CI matrix for MSVC (including /O2 builds)
it may also be worth cleaning up the code, as completion-token type deducing was added in asio-1.31, which allows us to get rid of the unnecessary bound_token variable before each call to async_initiate

@annihilatorq annihilatorq merged commit 74dafef into main Mar 9, 2026
19 checks passed
@annihilatorq
Copy link
Member Author

it may also be worth cleaning up the code, as completion-token type deducing was added in asio-1.31, which allows us to get rid of the unnecessary bound_token variable before each call to async_initiate

pr will be appreciated 😎. closed.

@annihilatorq annihilatorq deleted the co_composed-msvc-fix branch March 9, 2026 15:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant