[Lazarus] Help debugging

Antonio Fortuny a.fortuny at sitasoftware.lu
Wed Jan 11 16:21:12 CET 2012



Le 11/01/2012 16:01, Kjow a écrit :
> Hi all,
>
> I have a "random" crash that I can't debug on my program.
>
> I have a class that contains some other classes, variables, etc. On
> some point of execution the program creates the object class and in an
> other point it frees this object.
>
> I need to do this some times in the "timeline", e.g.:
>
> On class:
> "
> procedure TBody.InitOtherThings;
> ...
> obj2:= TSomeThing.create(nil);
> obj2.moveto(obj1);
> ...
> var2:= var1;
> ...
> "
>
> On "timeline":
> "
> ...
> body:= TBody.create;
> body.obj1:= Form1.obj1; //I need something like this
> body.var1:= 123;
> body.InitOtherThings;
> ...
> "
>
> On "timeline+2":
> "
> ...
> if assigned(body) Then
instead of
  body.free;
do
  FreeAndNil(body)

!! without this, the pointer to the object still contains the original 
pointer value.>:o
Do the same for other creations.
Common issue when reusing object pointers

> "
>
>
> On "timeline+3":
> "
> ...
> body:= TBody.create;
> body.obj1:= Form1.obj1; //I need something like this
> body.var1:= 123;
> body.InitOtherThings;
> ...
> "
>
> On "timeline+4":
> "
> ...
> if assigned(body) Then
>   body.free;
> "
>
> Of course, I'm sorry about this example... I wrote it as stupid
> example, without copy anything of original code (too complex).
>
> Anyway, everything works right, but after sometimes I create/free, I
> get a "SYSTEM_TOBJECT_$_FREE (18)" error, but I can't get the row in
> my source code where the error is generated. In attachment the window
> with the error.
>
> Thank you in advance.
> Kjow
>
> PS generally the crash happens after the third time I free the object.
> (Sometime it never happens)
>
> --
> _______________________________________________
> Lazarus mailing list
> Lazarus at lists.lazarus.freepascal.org
> http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus
>






More information about the Lazarus mailing list