[ADOL-C] inverse_tensor_eval memory error
Hoang Giang Bui
hgbk2008 at gmail.com
Thu Aug 3 17:32:12 EDT 2017
I checked that further and found that this example still works in v2.5.2
but fail at v2.6.0. I think that can be helpful for you to track down this
problem.
Best
Giang
On Thu, Aug 3, 2017 at 10:43 PM, Hoang Giang Bui <hgbk2008 at gmail.com> wrote:
> Hello
>
> I also got the error of inverse_tensor_eval. I executed the example
> in examples/additional_examples/taylor/coordinates and received the error
> below. I used ADOL-C 2.6.3
>
> COORDINATES (ADOL-C Example)
>
> Cartesian coordinates:
> z_1: (e.g. 4)
> 4
> z_2: (e.g. 3)
> 3
>
> Polar coordinates:
> z_3: (e.g. 5)
> 5
> z_4: (e.g. 0.64350110879 <06435%200110879>)
> 0.64
>
> Highest derivative degree = 3
> *** Error in `./coordinates': double free or corruption (out):
> 0x0000000000c8df90 ***
> Aborted (core dumped)
>
> Please help to take a look.
>
> Giang
>
> On Thu, Aug 3, 2017 at 8:32 PM, Brad Bell <bradbell at seanet.com> wrote:
>
>> I have am trying to run a simple example using inverse_tensor_eval. To be
>> specific
>> F(z) = sin(z)
>> I have been unable to figure out why I am getting memory errors when I
>> run the
>> code included below. When I run it in valgrind, I get the following
>> output:
>> ============================================================
>> =====================================
>> build>valgrind ./adolc
>> ==29183== Memcheck, a memory error detector
>> ==29183== Copyright (C) 2002-2015, and GNU GPL'd, by Julian Seward et al.
>> ==29183== Using Valgrind-3.12.0 and LibVEX; rerun with -h for copyright
>> info
>> ==29183== Command: ./adolc
>> ==29183==
>> ==29183== Invalid free() / delete / delete[] / realloc()
>> ==29183== at 0x4C2ED4A: free (vg_replace_malloc.c:530)
>> ==29183== by 0x4F8B731: inverse_tensor_eval (taylor.c:741)
>> ==29183== by 0x401094: main (adolc.cpp:37)
>> ==29183== Address 0x699cf38 is 8 bytes inside a block of size 32 alloc'd
>> ==29183== at 0x4C2FA50: calloc (vg_replace_malloc.c:711)
>> ==29183== by 0x4E63FA5: myalloc2 (adalloc.c:125)
>> ==29183== by 0x4F8B1B5: inverse_tensor_eval (taylor.c:688)
>> ==29183== by 0x401094: main (adolc.cpp:37)
>> ==29183==
>> ==29183== Invalid free() / delete / delete[] / realloc()
>> ==29183== at 0x4C2ED4A: free (vg_replace_malloc.c:530)
>> ==29183== by 0x4F8B74C: inverse_tensor_eval (taylor.c:743)
>> ==29183== by 0x401094: main (adolc.cpp:37)
>> ==29183== Address 0x699cf98 is 8 bytes inside a block of size 32 alloc'd
>> ==29183== at 0x4C2FA50: calloc (vg_replace_malloc.c:711)
>> ==29183== by 0x4E63FA5: myalloc2 (adalloc.c:125)
>> ==29183== by 0x4F8B1D2: inverse_tensor_eval (taylor.c:689)
>> ==29183== by 0x401094: main (adolc.cpp:37)
>> ==29183==
>> tensor[0][0] = 0.523599
>> tensor[0][1] = 1.1547
>> tensor[0][2] = 0.7698
>> z = 0.523599
>> zp = 1.1547
>> zpp = 0.7698
>> adolc: Done
>> ==29183==
>> ==29183== HEAP SUMMARY:
>> ==29183== in use at exit: 1,094 bytes in 20 blocks
>> ==29183== total heap usage: 107 allocs, 89 frees, 19,481,090 bytes
>> allocated
>> ==29183==
>> ==29183== LEAK SUMMARY:
>> ==29183== definitely lost: 104 bytes in 6 blocks
>> ==29183== indirectly lost: 8 bytes in 1 blocks
>> ==29183== possibly lost: 0 bytes in 0 blocks
>> ==29183== still reachable: 982 bytes in 13 blocks
>> ==29183== suppressed: 0 bytes in 0 blocks
>> ==29183== Rerun with --leak-check=full to see details of leaked memory
>> ==29183==
>> ==29183== For counts of detected and suppressed errors, rerun with: -v
>> ==29183== ERROR SUMMARY: 2 errors from 2 contexts (suppressed: 0 from 0)
>> build>
>> ============================================================
>> =====================================
>> # include <adolc/adolc.h>
>> int main(void)
>> {
>> int n = 1; // number of independent and dependent variables
>> int d = 2; // highest order derivative
>> int p = 1; // number of directions
>> int size = 3; // [(p + d) choose d] = (p+d-0) *...* (p+1) / (1 *...*
>> d)
>> //
>> double* S[1]; // seed matrix S[n][p]
>> S[0] = new double[p];
>> //
>> double* tensor[1]; // partials of z w.r.t x tensor[n][size]
>> tensor[0] = new double[size];
>>
>> // Set Seed matrix to identity
>> S[0][0] = 1.0;
>>
>> // independent and dependent variables
>> adouble az[1], ay[1]; // az[n], ay[n]
>> double z[1], y[1]; // z[n], y[n]
>>
>> // record operations for y = F(z) = sin(z)
>> short int tag = 1; // tape identifier
>> trace_on(tag); // start recording
>> z[0] = 1.0; // value during recording
>> az[0] <<= z[0]; // independent variable
>> ay[0] = sin(az[0]); // function evaluation
>> ay[0] >>= y[0]; // dependent variable
>> trace_off(); // turn off recording
>>
>> // evaluate inverse of F at x0
>> double x0 = 0.5; // argument for inverse
>> z[0] = std::asin(x0); // F^-1 (x0) = z0
>> inverse_tensor_eval(tag, n, d, p, z, tensor, S);
>>
>> // print tensor
>> for(int j = 0; j < size; j++)
>> { std::cout << "tensor[0][" << j << "] = " << tensor[0][j] << "\n";
>> }
>>
>> // derivative of F^-1 (x0) = 1.0 / sqrt( 1 - x0 * x0 )
>> double zp = 1.0 / std::sqrt(1.0 - x0 * x0 );
>>
>> // second derivative of F^-1 (x0) = x0 / sqrt( 1 - x0 * x0 )^3
>> double zpp = x0 * zp * zp * zp;
>>
>> // print derivatives for z
>> std::cout << "z = " << z[0] << "\n";
>> std::cout << "zp = " << zp << "\n";
>> std::cout << "zpp = " << zpp << "\n";
>> //
>> delete [] S[0];
>> delete [] tensor[0];
>> //
>> std::cout << "adolc: Done\n";
>> return 0;
>> }
>>
>> _______________________________________________
>> ADOL-C mailing list
>> ADOL-C at list.coin-or.org
>> https://urldefense.proofpoint.com/v2/url?u=https-3A__list.co
>> in-2Dor.org_mailman_listinfo_adol-2Dc&d=DwICAg&c=Ngd-ta5yRYs
>> qeUsEDgxhcqsYYY1Xs5ogLxWPA_2Wlc4&r=0eOhD1zcLnB9JhadNXrezwNw8
>> 7TYLa0fyHrxCkWC5J8&m=_Ons9tqju2E2RHmPQy2M4dxzTzDANdgNNsqJlGe
>> 3_xE&s=nCnpB-VNJPhm9DrrYdYukpvGjJLoI0XJjc321inwUW0&e=
>
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://list.coin-or.org/pipermail/adol-c/attachments/20170803/7b047610/attachment.html>
More information about the ADOL-C
mailing list