Re: [Lazarus] SIGSEGV with Debug only

2012-03-31 Thread Martin Schreiber

Am 31.03.2012 03:57, schrieb waldo kitty:

On 3/30/2012 04:28, Martin Schreiber wrote:

Am 30.03.2012 02:06, schrieb Daniel Simoes de Ameida:

I'm using Debug Info as Auto (-g) and Display Line numbers (-gl),
Heaptrace Unit is also active (-gh)in Debug mode ...

Any hints ?


Heaptrace fills freed memory with garbage. CurAnchorSide probably is
in a object
which already has been destroyed.


ewww :( in my ancient mind, it would be better to fill with null for
possible checks but then again ;) :P

Actually it is $F0. The purpose is that $F0F0F0F0 as pointer should 
throw a SIGSEGV. Another heaptrace signature is $DEADBEEF. If you see 
this address in a pointer of your data structs there probably is 
something wrong. ;-)


Martin Schreiber

--
___
Lazarus mailing list
Lazarus@lists.lazarus.freepascal.org
http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus


Re: [Lazarus] SIGSEGV with Debug only

2012-03-30 Thread Michael Schnell

A not initialized (running wild) pointer can behave like this.

-Michael

--
___
Lazarus mailing list
Lazarus@lists.lazarus.freepascal.org
http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus


Re: [Lazarus] SIGSEGV with Debug only

2012-03-30 Thread Martin Schreiber

Am 30.03.2012 02:06, schrieb Daniel Simoes de Ameida:

Hi All

I have a strange issue...

I'm currently using Lazarus 0.9.31 (update from SVN) with FPC 2.6.0

When I compile my application with debug information, I always get a
SIGSEGV when closing one of my forms,on line 4805 of control.inc
This Image http://imagebin.org/205899shows the error.

However, when compiling without debug information, the errors do not
occur (better this way) ..

I'm using Debug Info as Auto (-g) and Display Line numbers (-gl),
Heaptrace Unit is also active (-gh)in Debug mode ...

Any hints ?

Heaptrace fills freed memory with garbage. CurAnchorSide probably is in 
a object which already has been destroyed.


Martin

--
___
Lazarus mailing list
Lazarus@lists.lazarus.freepascal.org
http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus


Re: [Lazarus] SIGSEGV with Debug only

2012-03-30 Thread Daniel Simoes de Ameida
Bingo...

Is the HeapTrace.. I just removed HeapTrace Unit from Linking and the problem 
has gone... 

Thanks Martin
 

[]s Daniel

Conheça o Projeto ACBr - Automaçao Comercial Brasil
DJSystem a Loja Patrocinadora do ACBr




 De: Martin Schreiber mse00...@gmail.com
Para: lazarus@lists.lazarus.freepascal.org 
Enviadas: Sexta-feira, 30 de Março de 2012 5:28
Assunto: Re: [Lazarus] SIGSEGV with Debug only
 
Am 30.03.2012 02:06, schrieb Daniel Simoes de Ameida:
 Hi All

 I have a strange issue...

 I'm currently using Lazarus 0.9.31 (update from SVN) with FPC 2.6.0

 When I compile my application with debug information, I always get a
 SIGSEGV when closing one of my forms,on line 4805 of control.inc
 This Image http://imagebin.org/205899shows the error.

 However, when compiling without debug information, the errors do not
 occur (better this way) ..

 I'm using Debug Info as Auto (-g) and Display Line numbers (-gl),
 Heaptrace Unit is also active (-gh)in Debug mode ...

 Any hints ?

Heaptrace fills freed memory with garbage. CurAnchorSide probably is in 
a object which already has been destroyed.

Martin

--
___
Lazarus mailing list
Lazarus@lists.lazarus.freepascal.org
http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus


--
___
Lazarus mailing list
Lazarus@lists.lazarus.freepascal.org
http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus


Re: [Lazarus] SIGSEGV with Debug only

2012-03-30 Thread José Mejuto
Hello Lazarus-List,

Friday, March 30, 2012, 5:11:07 PM, you wrote:

DSdA Bingo...
DSdA Is the HeapTrace.. I just removed HeapTrace Unit from
DSdA Linking and the problem has gone... 

Removing heaptrace hide the error not fix the bug. The heaptrace is
showing you a bug that otherwise you will not be aware of it in most
situations like:

var
 a: TSomething;
begin
 a:=TSomething.Create;
 a.Method;
 a.Free;
 a.Method; //This is a bug that will be showed by heaptrace.
end;

-- 
Best regards,
 José


--
___
Lazarus mailing list
Lazarus@lists.lazarus.freepascal.org
http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus


Re: [Lazarus] SIGSEGV with Debug only

2012-03-30 Thread Martin

On 30/03/2012 16:11, Daniel Simoes de Ameida wrote:

Bingo...

Is the HeapTrace.. I just removed HeapTrace Unit from Linking and the 
problem has gone...


No it has not gone.

It is only hidden. That means you lowered the likelihood of it happening.

The code still accesses an object that does not exist. That means random 
memory.
Without heaptrc, you simple got better likelihood, that this random 
memory contains data, that does not cause a crash.

But the bug is still there. It may still crash...

Since it happens at form close, maybe you freed some component in your code?
Changed owner of a component (moving to other form)?
--
___
Lazarus mailing list
Lazarus@lists.lazarus.freepascal.org
http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus


Re: [Lazarus] SIGSEGV with Debug only

2012-03-30 Thread Daniel Simoes de Ameida
Martin,

Even doesn't changing the Owner, the problem still..

O forgot to mention the content of ChangeOwner function

 procedure ChangeOwner(AComponente, NewOwner: TComponent);
 begin
    AComponente.Owner.RemoveComponent(AComponente);
    NewOwner.InsertComponent(AComponente);
 end;

I suppose this function will handle all Notification changes, isn't ?

 
[]s Daniel

Conheça o Projeto ACBr - Automaçao Comercial Brasil
DJSystem a Loja Patrocinadora do ACBr




 De: Martin laza...@mfriebe.de
Para: Daniel Simoes de Ameida dopidan...@yahoo.com.br; Lazarus mailing list 
lazarus@lists.lazarus.freepascal.org 
Enviadas: Sexta-feira, 30 de Março de 2012 13:49
Assunto: Re: [Lazarus] SIGSEGV with Debug only
 

On 30/03/2012 17:14, Daniel Simoes de Ameida wrote: 


Martin,


I use a Tab Style interface... (TDI)... so, I change the Owner/Parent in this 
function:




  APage    := TFormPage.Create(nbForms) ;  // This will call 
TFormPage.SetAForm








procedure TFormPage.SetAForm(const AValue : TForm) ;
begin
  fsAForm := AValue ;

  Caption := fsAForm.Caption;
  Color   := fsAForm.Color;

  fsAForm.BorderStyle := bsNone ;   
  fsAForm.Align   := alClient ;  

  // Change  Aform Owner and Parent
  fsAForm.Parent := Self;
  ChangeOwner(fsAForm, Self);
  //  AForm.FreeNotification(APage);

I can't tell you 100% certain if this is related, but there is a
chance it is to do with  http://bugs.freepascal.org/view.php?id=21458

Setting the Owner of a component, does call Notify with opRemove 
and that breaks the FreeNotification system.

Whenever the LCL sets a component to know about another it uses
FreeNotification. So if one of the 2 is destroyed, the other one is
informed and wiss not attempt to access the destroyed component.

That also happens for anchors(since the 2 anchored components know
about each other, they need to know, if one is destroyed)

Due to the bug I mentioned, if you chang the owner, those
notifications may no longer work. Depending on the order of calls
and who knows whom, that can cause such a crash.

Do you need to change the owner, or can you live with changing the
parent only?

The parent should be enough for displaying it.

One of the things the owner will do, is clean up: if the owner is
destroyed, so is the owned component.
Maybe you can own things by the application?
     APage    := TFormPage.Create(Application) ;  




--
___
Lazarus mailing list
Lazarus@lists.lazarus.freepascal.org
http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus


Re: [Lazarus] SIGSEGV with Debug only

2012-03-30 Thread Martin

On 30/03/2012 20:54, Daniel Simoes de Ameida wrote:

Martin,

Even doesn't changing the Owner, the problem still..

O forgot to mention the content of ChangeOwner function

 procedure ChangeOwner(AComponente, NewOwner: TComponent);
 begin
AComponente.Owner.RemoveComponent(AComponente);
NewOwner.InsertComponent(AComponente);
 end;

I suppose this function will handle all Notification changes, isn't ?



That is not that easy to answer. That depends on who owns what... Maybe 
even which classes are involved. To answer that I would have to read 
through some of the RTL/LCL rcode myself.
It is not even sure that the bug is related to this. Though with the bug 
in place, I would avoid changing owners. It is possible with 
workarounds, but I can't foresee all the pitfalls.


I had a quick look at the LCL code. Anchors to not seem to use FreeNotify

When the app crashes, use the debugger, open the stack and make sure the 
frame selected is pointing to the source you posted (it may already be)
Then evaluate self and/or self.fname to see which components refers to 
the missing anchor.

That should help you find out which control the anchor pointed to.

Maybe that holds some clue.

Then you can debug again, and set breakpoints (in TControl.Destroy / wit 
condition on FName), and trying to find when the other control gets 
destroyed (if that is the problem, there are other possibilities...)



Sorry this answer may appear a bit vague. But tracking that kind of 
issue can be very hard.




--
___
Lazarus mailing list
Lazarus@lists.lazarus.freepascal.org
http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus


Re: [Lazarus] SIGSEGV with Debug only

2012-03-30 Thread waldo kitty

On 3/30/2012 04:28, Martin Schreiber wrote:

Am 30.03.2012 02:06, schrieb Daniel Simoes de Ameida:

I'm using Debug Info as Auto (-g) and Display Line numbers (-gl),
Heaptrace Unit is also active (-gh)in Debug mode ...

Any hints ?


Heaptrace fills freed memory with garbage. CurAnchorSide probably is in a object
which already has been destroyed.


ewww :( in my ancient mind, it would be better to fill with null for possible 
checks but then again ;) :P


--
___
Lazarus mailing list
Lazarus@lists.lazarus.freepascal.org
http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus


[Lazarus] SIGSEGV with Debug only

2012-03-29 Thread Daniel Simoes de Ameida
Hi All

I have a strange issue...

I'm currently using Lazarus 0.9.31 (update from SVN) with FPC 2.6.0
When I compile my application with debug information, I always get a SIGSEGV 
when closing one of my forms,on line 4805 of control.inc 
This Image shows the error.


However, when compiling without debug information, the errors do not occur 
(better this way) ..

I'm using Debug Info as Auto (-g) and Display Line numbers (-gl), Heaptrace 
Unit is also active (-gh)in Debug mode ...

Any hints ?


[]s Daniel

Conheça o Projeto ACBr - Automaçao Comercial Brasil
DJSystem a Loja Patrocinadora do ACBr
--
___
Lazarus mailing list
Lazarus@lists.lazarus.freepascal.org
http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus