Boost logo

Boost Users :

Subject: Re: [Boost-users] [boost::asio::serial_port] Calling cancel() causes Run-Time Check Failure #0 on Visual Studio 2010 SP1
From: Richard Rowlands (richard.rowlands_at_[hidden])
Date: 2012-03-15 10:41:30


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_at_[hidden]> 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_at_[hidden]
> http://lists.boost.org/mailman/listinfo.cgi/boost-users



Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net