Are you using Windows XP? If you are it is due to Win32 API CancelIo can only cancel IO requests from the same thread as the CancelIO request itself. Vista and later has CancelIoEx which can cancel IO requests from any thread. As I remember Boost Asio Serial checks whether CancelIoEx is supported and if not will throw an exception if it determines the CancelIo request is not on the same thread as the outstanding IO request.

Richard

On 15 March 2012 14:21, Igor R <boost.lists@gmail.com> wrote:
> This is a fatal error, there's no way to recover from it, and in release
> builds, a nasty message box appears. It happens when I call
> serial_port::cancel and Boost tries to throw some exception. The exact error
> is:
>
> Run-Time Check Failure #0 - The value of ESP was not properly saved across a
> function call.  This is usually a result of calling a function declared with
> one calling convention with a function pointer declared with a different
> calling convention.


I couldn't reproduce this crash (Boost 1.49, MSVC10, Win7), maybe
because I don't have any trafic on COM1, but any way -- asio objects
are not thread-safe, so it might be unsafe to call cancel() this way.
Instead, try using the following: ioService.post([&]
{serialPort.cancel();}); - and see if it helps.
_______________________________________________
Boost-users mailing list
Boost-users@lists.boost.org
http://lists.boost.org/mailman/listinfo.cgi/boost-users