valgrind question

Boyce Griffith griffith at cims.nyu.edu
Thu Jan 22 13:40:06 CST 2009


Satish Balay wrote:
> On Thu, 22 Jan 2009, Boyce Griffith wrote:
>> Running my code with Valgrind, I get a number of errors like the following:
>>
>> Invalid read of size 8
>>    at 0x6104C8F: UnPack_1 (vpscat.c:421)
>>    by 0x61047A4: VecScatterEnd_1 (vpscat.h:150)
>>    by 0x6133B2B: VecScatterEnd (vscat.c:1564)
>>    by 0xC6A258: IBTK::LDataManager::endDataRedistribution(int, int)
>> (LDataManager.C:1200)
>>    by 0xA0AEF2: IBAMR::IBStaggeredHierarchyIntegrator::regridHierarchy()
>> (IBStaggeredHierarchyIntegrator.C:1196)
>>    by 0xA0CF53:
>> IBAMR::IBStaggeredHierarchyIntegrator::advanceHierarchy(double)
>> (IBStaggeredHierarchyIntegrator.C:653)
>>    by 0x7308C4: main (main.C:798)
>>  Address 0xa66bfd0 is 496 bytes inside a block of size 528 alloc'd
>>    at 0x4A05FBB: malloc (vg_replace_malloc.c:207)
>>    by 0x63DCFAF: PetscMallocAlign (mal.c:40)
>>    by 0x63EA8A0: PetscTrMallocDefault (mtr.c:194)
>>    by 0x611BDB2: VecScatterCreate_PtoS (vpscat.c:1570)
>>    by 0x6121252: VecScatterCreate_StoP (vpscat.c:1946)
>>    by 0x6122D2D: VecScatterCreate_PtoP (vpscat.c:2123)
>>    by 0x6131B08: VecScatterCreate (vscat.c:1380)
>>    by 0xC6960F: IBTK::LDataManager::endDataRedistribution(int, int)
>> (LDataManager.C:1158)
>>    by 0xA0AEF2: IBAMR::IBStaggeredHierarchyIntegrator::regridHierarchy()
>> (IBStaggeredHierarchyIntegrator.C:1196)
>>    by 0xA0CF53:
>> IBAMR::IBStaggeredHierarchyIntegrator::advanceHierarchy(double)
>> (IBStaggeredHierarchyIntegrator.C:653)
>>    by 0x7308C4: main (main.C:798)
>>
>> Has anyone seen this kind of error crop up before?  Does it indicate that I am
>> messing up the call to VecScatterCreate?  (This VecScatter is being used to
>> scatter data between ghosted Vecs, and I wouldn't be shocked if I have made a
>> dumb mistake.)  Could Valgrind be returning a false positive?
> 
> Most likely valgrind is correct here. However its a challenge
> determining where exactly the bug is - that is causing this behavior..
> 
> Checking ScatterCreate() and ScatterBegin() - and making sure that
> same vector [or dupes] are specified to these routines is a start...
> 
> It is also possible that there was some other memory corruption much
> earlier than this piece of code that valgrind couldn't detect [so
> there is some garage already in some arrays]. And this garbage is now
> causing bad memory access - thus this error.

Hi, Satish --

All of these valgrind errors are related to VecGhosts.  Can I run into 
memory corruption problems if there are no local nodes associated with a 
particular processor, or if there are no ghost nodes associated with a 
particular processor?

Thanks,

-- Boyce



More information about the petsc-users mailing list