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.
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.
Darío Eduardo Ramos
Meditech S.A. www.meditech.com.ar
(+54) 01147603300, Interno 31
Av. Julio A. Roca 3456
Florida Oeste, Bs.As. Argentina