[
https://issues.apache.org/jira/browse/TS-3984?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=14997944#comment-14997944
]
Bryan Call commented on TS-3984:
--------------------------------
I was able to remove the const_cast from Request &Request::operator=(Request
&r) by removing the const in the incoming argument. However, I get errors when
trying to do the same with Request::Request(const Request &r).
I will commit as is, but if you have a suggestion on getting rid of the
const_cast I think it would be cleaner code. Here is the error I am getting:
{code}
In file included from dispatch.cc:26:0:
dispatch.h:54:8: warning: 'template<class> class std::auto_ptr' is deprecated
[-Wdeprecated-declarations]
std::auto_ptr<ats::io::IO> io;
^
In file included from /usr/include/c++/5.1.1/memory:81:0,
from dispatch.h:27,
from dispatch.cc:26:
/usr/include/c++/5.1.1/bits/unique_ptr.h:49:28: note: declared here
template<typename> class auto_ptr;
^
In file included from
/usr/include/c++/5.1.1/x86_64-redhat-linux/bits/c++allocator.h:33:0,
from /usr/include/c++/5.1.1/bits/allocator.h:46,
from /usr/include/c++/5.1.1/memory:63,
from dispatch.h:27,
from dispatch.cc:26:
/usr/include/c++/5.1.1/ext/new_allocator.h: In instantiation of 'void
__gnu_cxx::new_allocator<_Tp>::construct(_Up*, _Args&& ...) [with _Up =
Request; _Args = {Request}; _Tp = Request]':
/usr/include/c++/5.1.1/bits/alloc_traits.h:256:4: required from 'static
std::_Require<typename std::allocator_traits<_Alloc>::__construct_helper<_Tp,
_Args>::type> std::allocator_traits<_Alloc>::_S_construct(_Alloc&, _Tp*,
_Args&& ...) [with _Tp = Request; _Args = {Request}; _Alloc =
std::allocator<Request>; std::_Require<typename
std::allocator_traits<_Alloc>::__construct_helper<_Tp, _Args>::type> = void]'
/usr/include/c++/5.1.1/bits/alloc_traits.h:402:16: required from 'static
decltype (_S_construct(__a, __p,
(forward<_Args>)(std::allocator_traits::construct::__args)...))
std::allocator_traits<_Alloc>::construct(_Alloc&, _Tp*, _Args&& ...) [with _Tp
= Request; _Args = {Request}; _Alloc = std::allocator<Request>; decltype
(_S_construct(__a, __p,
(forward<_Args>)(std::allocator_traits::construct::__args)...)) = <type error>]'
/usr/include/c++/5.1.1/bits/vector.tcc:96:30: required from 'void
std::vector<_Tp, _Alloc>::emplace_back(_Args&& ...) [with _Args = {Request};
_Tp = Request; _Alloc = std::allocator<Request>]'
/usr/include/c++/5.1.1/bits/stl_vector.h:932:21: required from 'void
std::vector<_Tp, _Alloc>::push_back(std::vector<_Tp, _Alloc>::value_type&&)
[with _Tp = Request; _Alloc = std::allocator<Request>; std::vector<_Tp,
_Alloc>::value_type = Request]'
dispatch.cc:223:48: required from here
/usr/include/c++/5.1.1/ext/new_allocator.h:120:4: error: invalid initialization
of non-const reference of type 'Request&' from an rvalue of type 'Request'
{ ::new((void *)__p) _Up(std::forward<_Args>(__args)...); }
^
dispatch.cc:50:1: note: initializing argument 1 of
'Request::Request(Request&)'
Request::Request(Request &r) : host(r.host), length(r.length), io(r.io)
^
In file included from /usr/include/c++/5.1.1/memory:64:0,
from dispatch.h:27,
from dispatch.cc:26:
/usr/include/c++/5.1.1/bits/stl_construct.h: In instantiation of 'void
std::_Construct(_T1*, _Args&& ...) [with _T1 = Request; _Args = {Request}]':
/usr/include/c++/5.1.1/bits/stl_uninitialized.h:75:18: required from 'static
_ForwardIterator
std::__uninitialized_copy<_TrivialValueTypes>::__uninit_copy(_InputIterator,
_InputIterator, _ForwardIterator) [with _InputIterator =
std::move_iterator<Request*>; _ForwardIterator = Request*; bool
_TrivialValueTypes = false]'
/usr/include/c++/5.1.1/bits/stl_uninitialized.h:126:15: required from
'_ForwardIterator std::uninitialized_copy(_InputIterator, _InputIterator,
_ForwardIterator) [with _InputIterator = std::move_iterator<Request*>;
_ForwardIterator = Request*]'
/usr/include/c++/5.1.1/bits/stl_uninitialized.h:281:37: required from
'_ForwardIterator std::__uninitialized_copy_a(_InputIterator, _InputIterator,
_ForwardIterator, std::allocator<_Tp>&) [with _InputIterator =
std::move_iterator<Request*>; _ForwardIterator = Request*; _Tp = Request]'
/usr/include/c++/5.1.1/bits/stl_uninitialized.h:303:2: required from
'_ForwardIterator std::__uninitialized_move_if_noexcept_a(_InputIterator,
_InputIterator, _ForwardIterator, _Allocator&) [with _InputIterator = Request*;
_ForwardIterator = Request*; _Allocator = std::allocator<Request>]'
/usr/include/c++/5.1.1/bits/vector.tcc:422:8: required from 'void
std::vector<_Tp, _Alloc>::_M_emplace_back_aux(_Args&& ...) [with _Args =
{Request}; _Tp = Request; _Alloc = std::allocator<Request>]'
/usr/include/c++/5.1.1/bits/vector.tcc:101:23: required from 'void
std::vector<_Tp, _Alloc>::emplace_back(_Args&& ...) [with _Args = {Request};
_Tp = Request; _Alloc = std::allocator<Request>]'
/usr/include/c++/5.1.1/bits/stl_vector.h:932:21: required from 'void
std::vector<_Tp, _Alloc>::push_back(std::vector<_Tp, _Alloc>::value_type&&)
[with _Tp = Request; _Alloc = std::allocator<Request>; std::vector<_Tp,
_Alloc>::value_type = Request]'
dispatch.cc:223:48: required from here
/usr/include/c++/5.1.1/bits/stl_construct.h:75:7: error: invalid initialization
of non-const reference of type 'Request&' from an rvalue of type 'Request'
{ ::new(static_cast<void*>(__p)) _T1(std::forward<_Args>(__args)...); }
^
dispatch.cc:50:1: note: initializing argument 1 of
'Request::Request(Request&)'
Request::Request(Request &r) : host(r.host), length(r.length), io(r.io)
^
Makefile:738: recipe for target 'dispatch.lo' failed
make[3]: *** [dispatch.lo] Error 1
make[3]: Leaving directory
'/home/bcall/dev/apache/trafficserver/plugins/experimental/multiplexer'
Makefile:625: recipe for target 'all-recursive' failed
make[2]: *** [all-recursive] Error 1
make[2]: Leaving directory
'/home/bcall/dev/apache/trafficserver/plugins/experimental'
Makefile:615: recipe for target 'all-recursive' failed
make[1]: *** [all-recursive] Error 1
make[1]: Leaving directory '/home/bcall/dev/apache/trafficserver/plugins'
Makefile:670: recipe for target 'all-recursive' failed
make: *** [all-recursive] Error 1
{code}
> CID 1328817: Resource leaks (CTOR_DTOR_LEAK) in multiplexer plugin
> --------------------------------------------------------------------
>
> Key: TS-3984
> URL: https://issues.apache.org/jira/browse/TS-3984
> Project: Traffic Server
> Issue Type: Bug
> Components: Plugins
> Reporter: Leif Hedstrom
> Assignee: Bryan Call
> Fix For: 6.1.0
>
>
> {code}
> ** CID 1328817: Resource leaks (CTOR_DTOR_LEAK)
> /plugins/experimental/multiplexer/dispatch.cc: 39 in Request::Request(const
> std::basic_string<char, std::char_traits<char>, std::allocator<char>>&,
> tsapi_mbuffer *, tsapi_mloc *)()
> ________________________________________________________________________________________________________
> *** CID 1328817: Resource leaks (CTOR_DTOR_LEAK)
> /plugins/experimental/multiplexer/dispatch.cc: 39 in Request::Request(const
> std::basic_string<char, std::char_traits<char>, std::allocator<char>>&,
> tsapi_mbuffer *, tsapi_mloc *)()
> 33
> 34 extern Statistics statistics;
> 35
> 36 extern size_t timeout;
> 37
> 38 Request::Request(const std::string &h, const TSMBuffer b, const TSMLoc
> l)
> CID 1328817: Resource leaks (CTOR_DTOR_LEAK)
> The constructor allocates field "io" of "Request" but there is no
> destructor.
> 39 : host(h), length(TSHttpHdrLengthGet(b, l)), io(new ats::io::IO())
> 40 {
> 41 assert(!host.empty());
> 42 assert(b != NULL);
> 43 assert(l != NULL);
> 44 assert(io != NULL);
> {code}
--
This message was sent by Atlassian JIRA
(v6.3.4#6332)