Lee Clagett
2015-01-05 23:22:17 UTC
I was trying to use ASIO's async_result in another project, but ran into an
issue. In some situations I was trying to invoke the handler immediately,
instead of waiting on an operation. This resulted in an immediate
segmentation fault. A similar situation was described here [
https://github.com/BoostGSoC14/boost.http/issues/2 ]. The problem is that
the handler tries to switch the user-space thread to the user-space thread
currently in execution. Bjorn Reese fixed the issue by passing the handler
to io_service.post(), which meant the user-space thread was resumed on
another kernel-thread, after the user-space thread suspended on the current
kernel thread.
However, I think the io_service.post solution is still an issue. There
doesn't appear to be any synchronization inside of the async_result code
for boost::coroutine, so it should be possible for the handler to attempt a
switch to the user-space thread that is still executing on another kernel
thread. I think some synchronization object would have to be sent through
the boost::coroutine object itself, so that the handler would block until
the coroutine was properly suspended.
Lee
issue. In some situations I was trying to invoke the handler immediately,
instead of waiting on an operation. This resulted in an immediate
segmentation fault. A similar situation was described here [
https://github.com/BoostGSoC14/boost.http/issues/2 ]. The problem is that
the handler tries to switch the user-space thread to the user-space thread
currently in execution. Bjorn Reese fixed the issue by passing the handler
to io_service.post(), which meant the user-space thread was resumed on
another kernel-thread, after the user-space thread suspended on the current
kernel thread.
However, I think the io_service.post solution is still an issue. There
doesn't appear to be any synchronization inside of the async_result code
for boost::coroutine, so it should be possible for the handler to attempt a
switch to the user-space thread that is still executing on another kernel
thread. I think some synchronization object would have to be sent through
the boost::coroutine object itself, so that the handler would block until
the coroutine was properly suspended.
Lee