[boost] [thread] SEVERE bug on packaged_task constructor in C++11 mode.

6 views
Skip to first unread message

Vicente J. Botet Escriba

unread,
May 21, 2013, 2:24:50 AM5/21/13
to bo...@lists.boost.org, boost...@lists.boost.org
Hi,

There is a severe bug in packaged_task constructor when compiling in
C++11 mode and giving a copyable functor as parameter, as reported in
https://svn.boost.org/trac/boost/ticket/8596. I believe that this is not
a regression, this have never worked.

Until I find a fix, the packaged_task could be used only with free
functions and with movable functors when compiling in C++11 mode.

Fortunately there is no regression on C++98 compilers (at least not
identified yet).

Sorry for the disagreement,
Vicente

_______________________________________________
Unsubscribe & other changes: http://lists.boost.org/mailman/listinfo.cgi/boost

Andrey Semashev

unread,
May 21, 2013, 2:42:07 AM5/21/13
to bo...@lists.boost.org
On Tue, May 21, 2013 at 10:24 AM, Vicente J. Botet Escriba <
vicent...@wanadoo.fr> wrote:

> Hi,
>
> There is a severe bug in packaged_task constructor when compiling in C++11
> mode and giving a copyable functor as parameter, as reported in
> https://svn.boost.org/trac/**boost/ticket/8596<https://svn.boost.org/trac/boost/ticket/8596>.
> I believe that this is not a regression, this have never worked.
>
> Until I find a fix, the packaged_task could be used only with free
> functions and with movable functors when compiling in C++11 mode.
>
> Fortunately there is no regression on C++98 compilers (at least not
> identified yet).
>

Can C++11 code be disabled/removed (i.e. so that only C++03 working variant
is left) as a hotfix for 1.54? Or do you intend to fix it before the
release?

Vicente J. Botet Escriba

unread,
May 21, 2013, 1:40:20 PM5/21/13
to bo...@lists.boost.org
Le 21/05/13 08:42, Andrey Semashev a écrit :
> On Tue, May 21, 2013 at 10:24 AM, Vicente J. Botet Escriba <
> vicent...@wanadoo.fr> wrote:
>
>> Hi,
>>
>> There is a severe bug in packaged_task constructor when compiling in C++11
>> mode and giving a copyable functor as parameter, as reported in
>> https://svn.boost.org/trac/**boost/ticket/8596<https://svn.boost.org/trac/boost/ticket/8596>.
>> I believe that this is not a regression, this have never worked.
>>
>> Until I find a fix, the packaged_task could be used only with free
>> functions and with movable functors when compiling in C++11 mode.
>>
>> Fortunately there is no regression on C++98 compilers (at least not
>> identified yet).
>>
> Can C++11 code be disabled/removed (i.e. so that only C++03 working variant
> is left) as a hotfix for 1.54? Or do you intend to fix it before the
> release?
>
>
This is a possibility, but I'm not sure the C++11 users would add to
their movable classes the Boost.Move needed stuff.

Note that this is not a regression, but a feature that was delivered
with bugged behavior since the beginning. I will try to fix it as soon
as possible. I can not ensure this will however be done for 1.54.

Release managers could you give your advice?

Thanks,
Vicente

Vicente J. Botet Escriba

unread,
May 21, 2013, 3:58:44 PM5/21/13
to bo...@lists.boost.org
Le 21/05/13 08:24, Vicente J. Botet Escriba a écrit :
> Hi,
>
> There is a severe bug in packaged_task constructor when compiling in
> C++11 mode and giving a copyable functor as parameter, as reported in
> https://svn.boost.org/trac/boost/ticket/8596. I believe that this is
> not a regression, this have never worked.
>
> Until I find a fix, the packaged_task could be used only with free
> functions and with movable functors when compiling in C++11 mode.
>
>
I think that i have found why this was not working an fix it. The
forwarding from packaged task to the internal class was incorrect.

The following patch fix the example in ticket and works for all the
ts_packaged_task regression tests.

I'll commit this on trunk once the whole regression tests finish and pass.

Best,
Vicente

svn diff detail/config.hpp future.hpp
Index: detail/config.hpp
===================================================================
--- detail/config.hpp (revision 84336)
+++ detail/config.hpp (working copy)
@@ -13,8 +13,6 @@
#include <boost/thread/detail/platform.hpp>

//#define BOOST_THREAD_DONT_PROVIDE_INTERRUPTIONS
-
-
// ATTRIBUTE_MAY_ALIAS

#if defined(__GNUC__) && (__GNUC__ * 100 + __GNUC_MINOR__) > 302 \
@@ -95,9 +93,9 @@
#endif

/// RVALUE_REFERENCES_DONT_MATCH_FUNTION_PTR
-#if defined BOOST_NO_CXX11_RVALUE_REFERENCES || defined BOOST_MSVC
+//#if defined BOOST_NO_CXX11_RVALUE_REFERENCES || defined BOOST_MSVC
#define BOOST_THREAD_RVALUE_REFERENCES_DONT_MATCH_FUNTION_PTR
-#endif
+//#endif

// Default version
#if !defined BOOST_THREAD_VERSION
Index: future.hpp
===================================================================
--- future.hpp (revision 84336)
+++ future.hpp (working copy)
@@ -2275,18 +2275,12 @@
task_object(task_object&);
public:
F f;
-#ifndef BOOST_NO_CXX11_RVALUE_REFERENCES
- task_object(BOOST_THREAD_RV_REF(F) f_):
- f(boost::forward<F>(f_))
- {}
-#else
task_object(F const& f_):
f(f_)
{}
task_object(BOOST_THREAD_RV_REF(F) f_):
- f(boost::move(f_)) // TODO forward
+ f(boost::move(f_))
{}
-#endif

#if defined BOOST_THREAD_PROVIDES_SIGNATURE_PACKAGED_TASK &&
defined(BOOST_THREAD_PROVIDES_VARIADIC_THREAD)
void do_apply(BOOST_THREAD_RV_REF(ArgTypes) ... args)
@@ -2837,12 +2831,11 @@
#endif
#ifndef BOOST_NO_CXX11_RVALUE_REFERENCES
template <class F>
- explicit packaged_task(BOOST_THREAD_RV_REF(F) f
+ explicit packaged_task(BOOST_THREAD_FWD_REF(F) f
, typename disable_if<is_same<typename decay<F>::type,
packaged_task>, dummy* >::type=0
)
{
- //typedef typename remove_cv<typename
remove_reference<F>::type>::type FR;
- typedef F FR;
+ typedef typename remove_cv<typename
remove_reference<F>::type>::type FR;
#if defined BOOST_THREAD_PROVIDES_SIGNATURE_PACKAGED_TASK
#if defined(BOOST_THREAD_PROVIDES_VARIADIC_THREAD)
typedef detail::task_object<FR,R(ArgTypes...)>
task_object_type;
@@ -2921,10 +2914,9 @@

#if ! defined BOOST_NO_CXX11_RVALUE_REFERENCES
template <class F, class Allocator>
- packaged_task(boost::allocator_arg_t, Allocator a,
BOOST_THREAD_RV_REF(F) f)
+ packaged_task(boost::allocator_arg_t, Allocator a,
BOOST_THREAD_FWD_REF(F) f)
{
- //typedef typename remove_cv<typename
remove_reference<F>::type>::type FR;
- typedef F FR;
+ typedef typename remove_cv<typename
remove_reference<F>::type>::type FR;
#if defined BOOST_THREAD_PROVIDES_SIGNATURE_PACKAGED_TASK
#if defined(BOOST_THREAD_PROVIDES_VARIADIC_THREAD)
typedef detail::task_object<FR,R(ArgTypes...)> task_object_type;
iMac-de-Vicente-Botet-Escriba:thread viboes$

Eric Niebler

unread,
May 21, 2013, 5:25:15 PM5/21/13
to bo...@lists.boost.org
On 13-05-21 10:40 AM, Vicente J. Botet Escriba wrote:
> Le 21/05/13 08:42, Andrey Semashev a écrit :
>> On Tue, May 21, 2013 at 10:24 AM, Vicente J. Botet Escriba <
>> vicent...@wanadoo.fr> wrote:
>>
>>> Hi,
>>>
>>> There is a severe bug in packaged_task constructor when compiling in
>>> C++11
>>> mode and giving a copyable functor as parameter, as reported in
>>> https://svn.boost.org/trac/**boost/ticket/8596<https://svn.boost.org/trac/boost/ticket/8596>.
>>>
>>> I believe that this is not a regression, this have never worked.
>>>
>>> Until I find a fix, the packaged_task could be used only with free
>>> functions and with movable functors when compiling in C++11 mode.
>>>
>>> Fortunately there is no regression on C++98 compilers (at least not
>>> identified yet).
>>>
>> Can C++11 code be disabled/removed (i.e. so that only C++03 working
>> variant
>> is left) as a hotfix for 1.54? Or do you intend to fix it before the
>> release?
>>
> This is a possibility, but I'm not sure the C++11 users would add to
> their movable classes the Boost.Move needed stuff.
>
> Note that this is not a regression, but a feature that was delivered
> with bugged behavior since the beginning. I will try to fix it as soon
> as possible. I can not ensure this will however be done for 1.54.
>
> Release managers could you give your advice?

As you can see from the release schedule
(http://www.boost.org/development/index.html), the release branch is
open for bug fixes until next Monday. Get a fix checked into trunk and
let tests cycle. Then you can merge to release.

--
Eric Niebler
Boost.org

Vicente J. Botet Escriba

unread,
May 23, 2013, 3:27:44 PM5/23/13
to bo...@lists.boost.org
Le 21/05/13 23:25, Eric Niebler a écrit :
Committed revision https://svn.boost.org/trac/boost/changeset/84414.
A lot of the testers have already cycled this revision and the updated
test that check the bug pass on all of them.
I will merge on Saturday.

Best,
Vicente
Reply all
Reply to author
Forward
0 new messages