[CppAD] test error

Brad Bell bradbell at seanet.com
Sat Nov 14 12:09:24 EST 2015


I agree. The fix
https://github.com/coin-or/CppAD/commit/dc4d800a01f783c71ead9aa155315d679aac0611
seems to clear up the valgrind error.


On 11/13/2015 8:42 AM, Peter Caspers wrote:
> I think the guilty line is cppad/local/forward.hpp:208, which reads
>
> - const char* msg = ss.str().c_str();
>
> and should be replaced by
>
> + std::string tmp = ss.str();
> + const char* msg = tmp.c_str();
>
> since otherwise the msg pointer is invalid because ss.str() is destroyed.
>
> What do you think ?
>
>
> On 13 November 2015 at 16:48, Brad Bell <bradbell at seanet.com> wrote:
>> When I run
>>      valgrind -v ./test_one.exe
>>
>> I get:
>>
>> ==22734== Invalid read of size 1
>> ==22734==    at 0x4C2BC22: strlen (in
>> /usr/lib64/valgrind/vgpreload_memcheck-amd64-linux.so)
>> ==22734==    by 0x68DD140: UnknownInlinedFun (char_traits.h:263)
>> ==22734==    by 0x68DD140: std::basic_string<char, std::char_traits<char>,
>> std::allocator<char> >::basic_string(char const*, std::allocator<char>
>> const&) (basic_string.tcc:658)
>> ==22734==    by 0x404BDE: (anonymous namespace)::my_error_handler(bool, int,
>> char const*, char const*, char const*) (forward.cpp:192)
>> ==22734==    by 0x402D7B: CppAD::ErrorHandler::Call(bool, int, char const*,
>> char const*, char const*) (error_handler.hpp:182)
>> ==22734==    by 0x40E96E: CppAD::vector<double>
>> CppAD::ADFun<double>::Forward<CppAD::vector<double> >(unsigned long,
>> CppAD::vector<double> const&, std::ostream&) (forward.hpp:209)
>>
>> It appears that valgrind is complaining about the arguments to
>>      ErrorHandler::Call
>> at line 209 in
>>      cppad/local/forward.hpp
>> but these all look good and when I set a break point
>>      gdb ./test_one.exe
>>      b forward.cpp:192
>>      run
>> and at the break point I print the arguments, they all look in tact. Does
>> anything there look wrong to you ?
>>
>>
>>
>>
>> On 11/13/2015 7:03 AM, Peter Caspers wrote:
>>> Hi Brad,
>>>
>>> I do not exactly reproduce the error I had before. Repeating the steps
>>> you describe gives the same output as you write, so it looks ok at
>>> first sight.
>>>
>>> However running memcheck on the forward.cpp test case (valgrind
>>> ./test_one.exe) gives some invalid reads. I attach the log I get. Can
>>> you try to reproduce this on your side ?
>>>
>>> Thanks
>>> Peter
>>>
>>>
>> ... snip ...

... snip ...


More information about the CppAD mailing list