[petsc-users] No warning or error message of segmentation violation

Matthew Knepley knepley at gmail.com
Fri Nov 5 16:28:26 CDT 2010

On Fri, Nov 5, 2010 at 4:22 PM, Li, Zhisong (lizs) <lizs at mail.uc.edu> wrote:

>   Hi, Petsc Team,
> I use DA object to create structured data array based on global vectors.
> Recently, I checked my code and found an array with index out of range. But
> the code can run without any warning or segmentation violation message. At
> first I thought this might be a cache problem. But later I ran a simpler
> test code on another machine and it gave no error either. I did not use any
> periodic boundary setting.
> This never took place in the past from my experience, as Petsc could always
> detect any segmentation violation. So what's wrong with it this time? The
> following is the main part of my sequential test code:
>   DACreateGlobalVector(da, &elev);
>   VecSet(elev, 3.14159265);
>   DAVecGetArray(da, elev, &ele);
>   PetscPrintf(PETSC_COMM_WORLD, "ele[3][3][%D] is %4.3e\n", m+120,
> ele[3][3][m+120]);
>   DAVecRestoreArray(da, elev, &ele);
>   VecDestroy(elev);
>   DADestroy(daw);

PETSc detects write errors that take place directly after an array by
putting a sentinel value at the end. If it
is written over, CHKMEMQ will detect that. We have no way of checking for
overwrites of random memory
locations. If you try to write in some other users space, the OS will use a
SEGV signal, but you can freely
overwrite your own space.


> Thank you very much.
> Zhisong Li

What most experimenters take for granted before they begin their experiments
is infinitely more interesting than any results to which their experiments
-- Norbert Wiener
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.mcs.anl.gov/pipermail/petsc-users/attachments/20101105/8c37fbf3/attachment.htm>

More information about the petsc-users mailing list