[petsc-users] AddressSanitizer: attempting free on address which was not malloc()-ed

Matthew Knepley knepley at gmail.com
Wed Feb 27 09:24:26 CST 2019


You call VecDuplicate() a bunch, but VecDestroy() only once in the bottom
function. This is wrong.
Also, CHECK ALL RETURN CODES. This is the fastest way to find errors.

   Matt

On Wed, Feb 27, 2019 at 2:06 AM Yuyun Yang via petsc-users <
petsc-users at mcs.anl.gov> wrote:

> Hello team,
>
>
>
> I ran into the address sanitizer error that I hope you could help me with.
> I don’t really know what’s wrong with the way the code frees memory. The
> relevant code file is attached. The line number following domain.cpp
> specifically referenced to the vector _q, which seems a little odd, since
> some other vectors are constructed and freed the same way.
>
>
>
> ==1719==ERROR: AddressSanitizer: attempting free on address which was not
> malloc()-ed: 0x61f0000076c0 in thread T0
>
>     #0 0x7fbf195282ca in __interceptor_free
> (/usr/lib/x86_64-linux-gnu/libasan.so.2+0x982ca)
>
>     #1 0x7fbf1706f895 in PetscFreeAlign
> /home/yyy910805/petsc/src/sys/memory/mal.c:87
>
>     #2 0x7fbf1731a898 in VecDestroy_Seq
> /home/yyy910805/petsc/src/vec/vec/impls/seq/bvec2.c:788
>
>     #3 0x7fbf1735f795 in VecDestroy
> /home/yyy910805/petsc/src/vec/vec/interface/vector.c:408
>
>     #4 0x40dd0a in Domain::~Domain()
> /home/yyy910805/scycle/source/domain.cpp:132
>
>     #5 0x40b479 in main /home/yyy910805/scycle/source/main.cpp:242
>
>     #6 0x7fbf14d2082f in __libc_start_main
> (/lib/x86_64-linux-gnu/libc.so.6+0x2082f)
>
>     #7 0x4075d8 in _start (/home/yyy910805/scycle/source/main+0x4075d8)
>
>
>
> 0x61f0000076c0 is located 1600 bytes inside of 3220-byte region
> [0x61f000007080,0x61f000007d14)
>
> allocated by thread T0 here:
>
>     #0 0x7fbf19528b32 in __interceptor_memalign
> (/usr/lib/x86_64-linux-gnu/libasan.so.2+0x98b32)
>
>     #1 0x7fbf1706f7e0 in PetscMallocAlign
> /home/yyy910805/petsc/src/sys/memory/mal.c:41
>
>     #2 0x7fbf17073022 in PetscTrMallocDefault
> /home/yyy910805/petsc/src/sys/memory/mtr.c:183
>
>     #3 0x7fbf170710a1 in PetscMallocA
> /home/yyy910805/petsc/src/sys/memory/mal.c:397
>
>     #4 0x7fbf17326fb0 in VecCreate_Seq
> /home/yyy910805/petsc/src/vec/vec/impls/seq/bvec3.c:35
>
>     #5 0x7fbf1736f560 in VecSetType
> /home/yyy910805/petsc/src/vec/vec/interface/vecreg.c:51
>
>     #6 0x7fbf1731afae in VecDuplicate_Seq
> /home/yyy910805/petsc/src/vec/vec/impls/seq/bvec2.c:807
>
>     #7 0x7fbf1735eff7 in VecDuplicate
> /home/yyy910805/petsc/src/vec/vec/interface/vector.c:379
>
>     #8 0x4130de in Domain::setFields()
> /home/yyy910805/scycle/source/domain.cpp:431
>
>     #9 0x40c60a in Domain::Domain(char const*)
> /home/yyy910805/scycle/source/domain.cpp:57
>
>     #10 0x40b433 in main /home/yyy910805/scycle/source/main.cpp:242
>
>     #11 0x7fbf14d2082f in __libc_start_main
> (/lib/x86_64-linux-gnu/libc.so.6+0x2082f)
>
>
>
> SUMMARY: AddressSanitizer: bad-free ??:0 __interceptor_free
>
> ==1719==ABORTING
>
>
>
> Thanks very much!
>
> Yuyun
>


-- 
What most experimenters take for granted before they begin their
experiments is infinitely more interesting than any results to which their
experiments lead.
-- Norbert Wiener

https://www.cse.buffalo.edu/~knepley/ <http://www.cse.buffalo.edu/~knepley/>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.mcs.anl.gov/pipermail/petsc-users/attachments/20190227/5ace6240/attachment.html>


More information about the petsc-users mailing list