[petsc-users] How to use petsc in a dynamically loaded shared library?

Florian flo.44 at gmx.de
Sat Jul 21 12:26:48 CDT 2012


>On Fri, Jul 20, 2012 at 1:39 AM, Florian Beck <Flo.44 at gmx.de> 
>
>>
>> Hi,
>>
>>
>> On Thu, Jul 19, 2012 at 2:40 AM, Florian Beck <Flo.44 at gmx.de> wrote:
>>
>> >> In the debugger is the adress of my vector at the beginning and the end
>> >> the same, but if I look inside the vector the adress of ops, map and
>> >data
>> >> are 0x0 after I call the function VecDuplicate(). Is there a function to
>> >> synchronize the vectors before I destroy them?
>> >
>> >
>> >Sounds like a reference-counting bug. The most common cause is basically
>> >
>> >Vec X,Y;
>> >VecCreate(comm,&X);
>> >...
>> >Y = X;
>> >...
>> >VecDestroy(&X);
>> >VecDestroy(&Y);
>> >
>> >(perhaps spread across multiple functions, and perhaps with a reference
>> >obtained through a function that does not give you an "ownership share" by
>> >incrementing reference count).
>> >
>> >You can use "watch -l X->hdr.refct" in recent gdb to follow all the
>> >locations where reference count was changed (this includes the library),
>> >if
>> >you need a heavyweight methodology for tracking down the error.
>> >
>>
>> I have looked for the counting bug, but I haven't found anything because
>> my gdb crashes.
>>
>> Is it not possible to restore the addresses ops, map and data? I think
>> it's possible to get values and from the vectors, so why shouldn't it
>> possible to destroy them? Or is it possible to destroy the Vectors manually?
>>
>
>1) This has nothing to do with shared libraries. You have a bug in your>
>code.
>
>2)  Debugging is about making your code simpler until you can find the bug,
>and
>     learning to use debugging tools. This is a big part of programming.>
>
>3) Of course, you can destroy Vecs. You have a bug. Try using valgrind.

I made it to step with gdb now in VecCreate(). The problem is inside the VecCreate 
function the new created vector vec has all the adresses set. But when I'm stepping 
back in my function the addresses are all 0x0.

Another question is, what happens with my created vector. I mean I create a Object
with Vec v and inside the VecCreate function the addres of my object v is first set
to PETSC_NULL and later to the Vec which is created inside the VecCreate function.
It seems like I never could destroy my created vector. Can somebody explain this to me?



More information about the petsc-users mailing list