[Boost-bugs] [Boost C++ Libraries] #8596: With C++0x enabled, boost::packaged_task stores a reference to function objects, instead of a copy
- Next message: Boost C++ Libraries: "Re: [Boost-bugs] [Boost C++ Libraries] #7865: error: unknown target CPU 'i386' for the boost b2 build using architecture=x86 address-model=32"
- Previous message: Boost C++ Libraries: "Re: [Boost-bugs] [Boost C++ Libraries] #8586: Boost Thread .join() causes exception"
- Next in thread: Boost C++ Libraries: "Re: [Boost-bugs] [Boost C++ Libraries] #8596: With C++0x enabled, boost::packaged_task stores a reference to function objects, instead of a copy"
- Reply: Boost C++ Libraries: "Re: [Boost-bugs] [Boost C++ Libraries] #8596: With C++0x enabled, boost::packaged_task stores a reference to function objects, instead of a copy"
- Reply: Boost C++ Libraries: "Re: [Boost-bugs] [Boost C++ Libraries] #8596: With C++0x enabled, boost::packaged_task stores a reference to function objects, instead of a copy"
- Reply: Boost C++ Libraries: "Re: [Boost-bugs] [Boost C++ Libraries] #8596: With C++0x enabled, boost::packaged_task stores a reference to function objects, instead of a copy"
- Reply: Boost C++ Libraries: "Re: [Boost-bugs] [Boost C++ Libraries] #8596: With C++0x enabled, boost::packaged_task stores a reference to function objects, instead of a copy"
- Reply: Boost C++ Libraries: "Re: [Boost-bugs] [Boost C++ Libraries] #8596: With C++0x enabled, boost::packaged_task stores a reference to function objects, instead of a copy"
- Reply: Boost C++ Libraries: "Re: [Boost-bugs] [Boost C++ Libraries] #8596: With C++0x enabled, boost::packaged_task stores a reference to function objects, instead of a copy"
- Reply: Boost C++ Libraries: "Re: [Boost-bugs] [Boost C++ Libraries] #8596: With C++0x enabled, boost::packaged_task stores a reference to function objects, instead of a copy"
- Reply: Boost C++ Libraries: "Re: [Boost-bugs] [Boost C++ Libraries] #8596: With C++0x enabled, boost::packaged_task stores a reference to function objects, instead of a copy"
- Reply: Boost C++ Libraries: "Re: [Boost-bugs] [Boost C++ Libraries] #8596: With C++0x enabled, boost::packaged_task stores a reference to function objects, instead of a copy"
- Reply: Boost C++ Libraries: "Re: [Boost-bugs] [Boost C++ Libraries] #8596: With C++0x enabled, boost::packaged_task stores a reference to function objects, instead of a copy"
- Reply: Boost C++ Libraries: "Re: [Boost-bugs] [Boost C++ Libraries] #8596: With C++0x enabled, boost::packaged_task stores a reference to function objects, instead of a copy"
- Reply: Boost C++ Libraries: "Re: [Boost-bugs] [Boost C++ Libraries] #8596: With C++0x enabled, boost::packaged_task stores a reference to function objects, instead of a copy"
#8596: With C++0x enabled, boost::packaged_task stores a reference to function
objects, instead of a copy
----------------------------------------------------------+-----------------
Reporter: Kees-Jan Dijkzeul <kees-jan.dijkzeul@â¦> | Owner: anthonyw
Type: Bugs | Status: new
Milestone: To Be Determined | Component: thread
Version: Boost 1.53.0 | Severity: Problem
Keywords: |
----------------------------------------------------------+-----------------
I have build a Treadpool using boost::thread. In porting it to boost 1.53,
I've found a regression.
Consider attached test-program. It runs correctly on boost 1.49 and
earlier. It runs correctly on boost 1.53, with C++0x disabled. With C++0x
enabled, it crashes due to an uncaught exception "call to empty
boost::function"
Failure has been observed on Ubuntu Saucy, I.e. boost 1.53, gcc 4.8.0,
linux kernel 3.9.0.
After some debugging, I believe the problem is caused by packaged_task
storing a reference to the boost::function object, instead of a copy. As
the boost::function object is a temporary, this leads to undefined
behavior further on.
I'm guessing this problem is introduced in [81117] By below patch to
boost/thread/future.hpp
{{{
#ifndef BOOST_NO_CXX11_RVALUE_REFERENCES
template <class F>
explicit packaged_task(BOOST_THREAD_RV_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 typename remove_cv<typename
remove_reference<F>::type>::type FR;
+ typedef F FR;
#if defined BOOST_THREAD_PROVIDES_SIGNATURE_PACKAGED_TASK
....
}}}
Attached: Small application showing the problem
For original code please visit https://github.com/kees-
jan/scroom/blob/master/inc/scroom/impl/threadpoolimpl.hh#L90
--
Ticket URL: <https://svn.boost.org/trac/boost/ticket/8596>
Boost C++ Libraries <http://www.boost.org/>
Boost provides free peer-reviewed portable C++ source libraries.
- Next message: Boost C++ Libraries: "Re: [Boost-bugs] [Boost C++ Libraries] #7865: error: unknown target CPU 'i386' for the boost b2 build using architecture=x86 address-model=32"
- Previous message: Boost C++ Libraries: "Re: [Boost-bugs] [Boost C++ Libraries] #8586: Boost Thread .join() causes exception"
- Next in thread: Boost C++ Libraries: "Re: [Boost-bugs] [Boost C++ Libraries] #8596: With C++0x enabled, boost::packaged_task stores a reference to function objects, instead of a copy"
- Reply: Boost C++ Libraries: "Re: [Boost-bugs] [Boost C++ Libraries] #8596: With C++0x enabled, boost::packaged_task stores a reference to function objects, instead of a copy"
- Reply: Boost C++ Libraries: "Re: [Boost-bugs] [Boost C++ Libraries] #8596: With C++0x enabled, boost::packaged_task stores a reference to function objects, instead of a copy"
- Reply: Boost C++ Libraries: "Re: [Boost-bugs] [Boost C++ Libraries] #8596: With C++0x enabled, boost::packaged_task stores a reference to function objects, instead of a copy"
- Reply: Boost C++ Libraries: "Re: [Boost-bugs] [Boost C++ Libraries] #8596: With C++0x enabled, boost::packaged_task stores a reference to function objects, instead of a copy"
- Reply: Boost C++ Libraries: "Re: [Boost-bugs] [Boost C++ Libraries] #8596: With C++0x enabled, boost::packaged_task stores a reference to function objects, instead of a copy"
- Reply: Boost C++ Libraries: "Re: [Boost-bugs] [Boost C++ Libraries] #8596: With C++0x enabled, boost::packaged_task stores a reference to function objects, instead of a copy"
- Reply: Boost C++ Libraries: "Re: [Boost-bugs] [Boost C++ Libraries] #8596: With C++0x enabled, boost::packaged_task stores a reference to function objects, instead of a copy"
- Reply: Boost C++ Libraries: "Re: [Boost-bugs] [Boost C++ Libraries] #8596: With C++0x enabled, boost::packaged_task stores a reference to function objects, instead of a copy"
- Reply: Boost C++ Libraries: "Re: [Boost-bugs] [Boost C++ Libraries] #8596: With C++0x enabled, boost::packaged_task stores a reference to function objects, instead of a copy"
- Reply: Boost C++ Libraries: "Re: [Boost-bugs] [Boost C++ Libraries] #8596: With C++0x enabled, boost::packaged_task stores a reference to function objects, instead of a copy"
- Reply: Boost C++ Libraries: "Re: [Boost-bugs] [Boost C++ Libraries] #8596: With C++0x enabled, boost::packaged_task stores a reference to function objects, instead of a copy"
- Reply: Boost C++ Libraries: "Re: [Boost-bugs] [Boost C++ Libraries] #8596: With C++0x enabled, boost::packaged_task stores a reference to function objects, instead of a copy"
This archive was generated by hypermail 2.1.7
: 2017-02-16 18:50:13 UTC