SIGSEGV in fpc_check_object

classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

SIGSEGV in fpc_check_object

Gabor Boros-2
Hi All,

In my Lazarus application I use a TPanel descendant component (TMyPanel)
which have subpanels (TMySubPanel) which are TPanel descendants also.
The subpanels accessed through a TList. If add a new subpanel into the
main panel added to the list with TList.Add if remove a subpanel from it
remove from the list with TList.Remove then call TMySubPanel.Free. My
main development platform is x86_64-Linux and the application works like
a charm. But with the Windows version of the app (cross compiled to
i386-Win32) got an "Access violation." at TMySubPanel.Free. If start
with gdb got "Program received signal SIGSEGV, Segmentation fault.
0x004041c4 in fpc_check_object ()" at TMySubPanel.Free.

I completely don't understand what is the source of the problem and why
the two platforms behaves differently.

Cannot have a simple test case just a dumb example.

procedure TForm1.FormCreate(Sender: TObject);
var
   x:TPanel;

begin
   x.Free;
end;

With Linux no error (x is Nil before the Free call), with Windows got
SIGSEGV (x is not Nil before the Free call). Is it a Lazarus thing or
come from FPC?

Gabor
_______________________________________________
fpc-pascal maillist  -  [hidden email]
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: SIGSEGV in fpc_check_object

José Mejuto
El 13/06/2017 a las 21:04, Gabor Boros escribió:

> Cannot have a simple test case just a dumb example.
>
> procedure TForm1.FormCreate(Sender: TObject);
> var
>    x:TPanel;
>
> begin
>    x.Free;
> end;
>
> With Linux no error (x is Nil before the Free call), with Windows got
> SIGSEGV (x is not Nil before the Free call). Is it a Lazarus thing or
> come from FPC?

Hello,

That's wrong for sure, x is not initialized to nil, not in Linux nor in
Windows. Procedure variables must be always initialized by hand. With
that code you will get a warning from the compiler about uninitialized
variable use.

--

_______________________________________________
fpc-pascal maillist  -  [hidden email]
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: SIGSEGV in fpc_check_object

Gabor Boros-2
2017. 06. 14. 10:28 keltezéssel, José Mejuto írta:
> That's wrong for sure, x is not initialized to nil, not in Linux nor in
> Windows.

With the below code caption of the form not changed on Linux for me.

procedure TForm1.FormCreate(Sender: TObject);
var
   x:TPanel;

begin
   if Assigned(x) then Caption:='Assigned';
end;

Gabor
_______________________________________________
fpc-pascal maillist  -  [hidden email]
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: SIGSEGV in fpc_check_object

Free Pascal - General mailing list

Am 14.06.2017 11:13 schrieb "Gabor Boros" <[hidden email]>:
>
> 2017. 06. 14. 10:28 keltezéssel, José Mejuto írta:
>>
>> That's wrong for sure, x is not initialized to nil, not in Linux nor in Windows.
>
>
> With the below code caption of the form not changed on Linux for me.
>
>
> procedure TForm1.FormCreate(Sender: TObject);
> var
>   x:TPanel;
>
> begin
>   if Assigned(x) then Caption:='Assigned';
> end;

In this example the content of "x" is undefined as it's a local variable. The value of it is simply what is currently on the stack which *can* be Nil.

Regards,
Sven


_______________________________________________
fpc-pascal maillist  -  [hidden email]
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
Loading...