Opened 5 years ago

Last modified 5 years ago

#13317 new Bugs

io_service behaviour difference between ubuntu and msvc-14

Reported by: Diego Barrios Romero <eldruin@…> Owned by: chris_kohlhoff
Milestone: To Be Determined Component: asio
Version: Boost 1.62.0 Severity: Problem
Keywords: Cc:

Description

When implementing a basic thread pool using boost::asio::io_service, I am observing some differences in how queued tasks are handled when stopping the io_service.

On MSVC 14 (MS Visual Studio 2015), for some reason the queued tasks which were not started yet are not dropped when stopping the io_service but are run nonetheless. These tasks are dropped when running this on Ubuntu 16.04 (GCC 5.4.0).

I have simplified and cleaned up the original tests and put them in a single file (attached) which only depends on boost and uses some sleeps to demonstrate the problem. You can build it with the CMakeLists.txt attached if you wish.

The output on Ubuntu is as expected:

checkAllWorkIsProcessedBeforeDestruction
	passed.
	passed.
	passed.
checkWorkCanBeCancelled
	passed.
	passed.
	passed.
checkWorkCanBeInterrupted
	passed.
	passed.
	passed.
checkUninterruptableWorkIsNotInterruptedButCanBeDropped
	passed.
	passed.
	passed.
	passed.

This is the output on MSVC 14:

checkAllWorkIsProcessedBeforeDestruction
        passed.
        passed.
        passed.
checkWorkCanBeCancelled
        Error: functor 1 call expected: false current: true
        Error: functor 2 call expected: false current: true
        Error: running time expected: 150 current: 402
checkWorkCanBeInterrupted
        passed.
        passed.
        passed.
checkUninterruptableWorkIsNotInterruptedButCanBeDropped
        passed.
        Error: functor 2 call expected: false current: true
        passed.
        Error: running time expected: 250 current: 404

Am I doing something wrong?

Attachments (2)

ThreadPoolTests.cpp (4.4 KB ) - added by Diego Barrios Romero <eldruin@…> 5 years ago.
Test showing the problem
CMakeLists.txt (361 bytes ) - added by Diego Barrios Romero <eldruin@…> 5 years ago.

Download all attachments as: .zip

Change History (3)

by Diego Barrios Romero <eldruin@…>, 5 years ago

Attachment: ThreadPoolTests.cpp added

Test showing the problem

by Diego Barrios Romero <eldruin@…>, 5 years ago

Attachment: CMakeLists.txt added

comment:1 by Diego Barrios Romero <eldruin@…>, 5 years ago

I have reported the underlying bug on #13337, found after further investigation. This bug should be closed as the code is more complicated and contains a race.

Note: See TracTickets for help on using tickets.