* * *

Author Topic: Error: Security raised exception class 'External:SIGSEGV'.  (Read 1555 times)

mundim

  • New member
  • *
  • Posts: 11
Error: Security raised exception class 'External:SIGSEGV'.
« on: January 30, 2012, 12:10:52 am »
Hi, it's my first program in Lazarus. It's a simple program using Check boxes, so the program was doing fine until I added the last, a code that would make the program close when someone selected the right combination of boxes. After I had some trouble caming with a code that worked, I come with this code:

If CheckBox1.Checked and CheckBox5.Checked and CheckBox11.Checked and CheckBox14.Checked and CheckBox16.Checked then Close;

According to Lazarus the line has no problem, the program compils all the code without any problems but then there's this Error message "Security raised exception class 'External:SIGSEGV'." ; and the that line of code whom I'm talking about becomes highlithed in grey and a green arrow appears next to the number of the line... If I take this line out, the program works without any error message, so I guess the problem is in there.

Thanks for reading and please post if you can help me. Sorry if this is an obvious question, you see, I'm really starting to learn proggraming and I'm only 13...

IndianaJones

  • Sr. Member
  • ****
  • Posts: 408
Re: Error: Security raised exception class 'External:SIGSEGV'.
« Reply #1 on: January 30, 2012, 01:02:13 am »

It seems to me that the there is nothing wrong with the If statement, you can change the "close" part with the following code and check it is fine or not. it is a simple debugging hint to check the code is in the proper line.

ShowMessage('Hi');

Martin_fr

  • Hero Member
  • *****
  • Posts: 1218
Re: Error: Security raised exception class 'External:SIGSEGV'.
« Reply #2 on: January 30, 2012, 01:05:19 am »
"Security" is the name of your app or the function with that line?

Anyway "SigSegV" is often caused by something not initialized or already deleted.

So the actual error can be anywhere before.
Like if you would do
Code: [Select]
  CheckBox1.Destroy;
That is valid (though very unusual). So it would not cause any error.
But Checkbox would be invalid after that and the next time you access it, you get that error.


The checkboxes are all shown on your form? And that code belongs to a form, that is visible at that time?


mundim

  • New member
  • *
  • Posts: 11
Re: Error: Security raised exception class 'External:SIGSEGV'.
« Reply #3 on: January 30, 2012, 01:20:46 am »
I tried to replace the Close with the Hi message and still got the error... =/

Security is just the name of the project...

And yeah the all the checkboxes appear on the form at all time. It's basically, a page with 5 questions and 4 boxes for each question... I can post the code if you see anything wrong, but it looks like the problem is with that line and I have references to the boxes in order lines of code tha works properly...

Code: [Select]
unit Unit1;

{$mode objfpc}{$H+}

interface

uses
  Classes, SysUtils, FileUtil, Forms, Controls, Graphics, Dialogs, StdCtrls;

type

  { TForm1 }

  TForm1 = class(TForm)
    CC: TCheckBox;
    IV: TCheckBox;
    II: TCheckBox;
    V: TCheckBox;
    III: TCheckBox;
    Label6: TLabel;
    RSS: TCheckBox;
    GFD: TCheckBox;
    SAP: TCheckBox;
    SoWL: TCheckBox;
    Label5: TLabel;
    SoT: TCheckBox;
    DSOD: TCheckBox;
    SuAP: TCheckBox;
    KBT: TCheckBox;
    Java: TCheckBox;
    CSS: TCheckBox;
    HTML: TCheckBox;
    Label4: TLabel;
    Pascal: TCheckBox;
    Lazarus: TCheckBox;
    Delphi: TCheckBox;
    Microsoft: TCheckBox;
    Label1: TLabel;
    Label2: TLabel;
    Label3: TLabel;
    procedure CCClick(Sender: TObject);
    procedure CSSClick(Sender: TObject);
    procedure DelphiClick(Sender: TObject);
    procedure DSODClick(Sender: TObject);


    procedure GFDClick(Sender: TObject);
    procedure HTMLClick(Sender: TObject);
    procedure IIClick(Sender: TObject);
    procedure IIIClick(Sender: TObject);
    procedure IVClick(Sender: TObject);
    procedure JavaClick(Sender: TObject);
    procedure KBTClick(Sender: TObject);
    procedure LazarusClick(Sender: TObject);
    procedure MicrosoftClick(Sender: TObject);
    procedure PascalClick(Sender: TObject);
    procedure RSSClick(Sender: TObject);
    procedure SAPClick(Sender: TObject);
    procedure SoTClick(Sender: TObject);
    procedure SoWLClick(Sender: TObject);
    procedure SuAPClick(Sender: TObject);
    procedure VClick(Sender: TObject);


  private
    { private declarations }
  public
    { public declarations }
  end;

var
  Form1: TForm1;
  CC: TCheckBox;
    IV: TCheckBox;
    II: TCheckBox;
    V: TCheckBox;
    III: TCheckBox;
    Label6: TLabel;
    RSS: TCheckBox;
    GFD: TCheckBox;
    SAP: TCheckBox;
    SoWL: TCheckBox;
    Label5: TLabel;
    SoT: TCheckBox;
    DSOD: TCheckBox;
    SuAP: TCheckBox;
    KBT: TCheckBox;
    Java: TCheckBox;
    CSS: TCheckBox;
    HTML: TCheckBox;
    Label4: TLabel;
    Pascal: TCheckBox;
    Lazarus: TCheckBox;
    Delphi: TCheckBox;
    Microsoft: TCheckBox;



implementation

{$R *.lfm}

{ TForm1 }













procedure TForm1.MicrosoftClick(Sender: TObject);
begin
  CC.Enabled := False;
  Lazarus.Enabled := False ;
  Delphi.Enabled := False ;
end;

procedure TForm1.PascalClick(Sender: TObject);
begin
  HTML.Enabled :=False  ;
  CSS.Enabled := False ;
  Java.Enabled := False  ;
end;

procedure TForm1.RSSClick(Sender: TObject);
begin
  GFD.Enabled := False;
  SAP.Enabled := False;
  SoWL.Enabled := False  ;
end;

procedure TForm1.SAPClick(Sender: TObject);
begin
  GFD.Enabled := False ;
  RSS.Enabled := False   ;
  SoWL.Enabled := False   ;

end;

procedure TForm1.SoTClick(Sender: TObject);
begin
  DSOD.Enabled := False ;
  KBT.Enabled := False   ;
  SuAP.Enabled := False  ;
end;

procedure TForm1.SoWLClick(Sender: TObject);
begin
  RSS.Enabled := False;
  SAP.Enabled := False ;
  GFD.Enabled := False ;
end;

procedure TForm1.SuAPClick(Sender: TObject);
begin
  SoT.Enabled := False ;
  DSOD.Enabled := False ;
  KBT.Enabled := False  ;
end;

procedure TForm1.VClick(Sender: TObject);
begin
  III.Enabled := False  ;
  II.Enabled := False    ;
  IV. Enabled := False    ;
end;

procedure TForm1.DelphiClick(Sender: TObject);
begin
  CC.Enabled := False;
  Lazarus. Enabled := False;
  Microsoft. Enabled := False;
end;

procedure TForm1.DSODClick(Sender: TObject);
begin
  SoT.Enabled := False;
  SuAP.Enabled := False;
  KBT.Enabled := False;

end;







procedure TForm1.GFDClick(Sender: TObject);
begin
  SoWL.Enabled := False ;
  RSS.Enabled := False  ;
  SAP.Enabled := False  ;
end;

procedure TForm1.HTMLClick(Sender: TObject);
begin
 CSS.Enabled := False ;
  Java.Enabled := False  ;
  Pascal.Enabled := False  ;
end;

procedure TForm1.IIClick(Sender: TObject);
begin
  V.Enabled := False   ;
  III.Enabled := False  ;
  IV.Enabled := False    ;

end;

procedure TForm1.IIIClick(Sender: TObject);
begin
  II.Enabled := False   ;
  V.Enabled := False   ;
  IV. Enabled := False;
end;

procedure TForm1.IVClick(Sender: TObject);
begin
  V.Enabled := False    ;
  III.Enabled := False ;
  II. Enabled := False;
end;

procedure TForm1.JavaClick(Sender: TObject);
begin
  Pascal.Enabled := False  ;
  CSS.Enabled := False  ;
  HTML.Enabled := False  ;
end;

procedure TForm1.KBTClick(Sender: TObject);
begin
  SuAP.Enabled := False;
  SoT.Enabled := False;
  DSOD.Enabled := False ;
end;

procedure TForm1.CCClick(Sender: TObject);
begin
   Lazarus. Enabled := False;
   Microsoft. Enabled := False;
   Delphi.Enabled := False ;
end;

procedure TForm1.CSSClick(Sender: TObject);
begin
  Java.Enabled := False  ;
  Pascal.Enabled := False  ;
  HTML.Enabled := False  ;
end;

procedure TForm1.LazarusClick(Sender: TObject);
begin
   CC.Enabled := False;
  Microsoft. Enabled := False;
  Delphi.Enabled := False ;
end;
 begin
  If Lazarus.Checked and Pascal.Checked and DSOD.Checked and RSS.Checked and III.Checked then Exit;

end.
                                                                                             
                                                                                             

Except for those last lines of code, it's basically the same thing, the codes make you unable of changing the box you checked (after you click one of the 4 boxes for a question you can't change that answer...)
« Last Edit: January 30, 2012, 01:23:04 am by mundim »

IndianaJones

  • Sr. Member
  • ****
  • Posts: 408
Re: Error: Security raised exception class 'External:SIGSEGV'.
« Reply #4 on: January 30, 2012, 02:41:35 am »
If you define any object in the var section you have to create it dynamically so you dont need to declare those variables in the var section. Also you dont need to define 'begin' at the end of the program.

begin // You dont need to define this
  If Lazarus.Checked and Pascal.Checked and DSOD.Checked and RSS.Checked and III.Checked then Exit;

end.

Here is a simple example to show how to create objects statically and dynamically.

Code: [Select]
unit Unit1;

{$mode objfpc}{$H+}

interface

uses
  Classes, SysUtils, FileUtil, Forms, Controls, Graphics, Dialogs, StdCtrls;

type

  { TForm1 }

  TForm1 = class(TForm)
    CheckBox1: TCheckBox;
    CheckBox2: TCheckBox;
    procedure SMessage(Sender: TObject);
    procedure FormCreate(Sender: TObject);
  private
    { private declarations }
  public
    { public declarations }
  end;

var
  Form1: TForm1;
  Check1, Check2: TCheckBox;

implementation

{$R *.lfm}

{ TForm1 }

procedure TForm1.SMessage(Sender: TObject);
begin
    if CheckBox1.Checked and CheckBox2.Checked then ShowMessage('Hi');
    if Check1.Checked and Check2.Checked then ShowMessage('Hi');
end;

procedure TForm1.FormCreate(Sender: TObject);
begin
    CheckBox1.OnClick:=@SMessage;
    CheckBox2.OnClick:=@SMessage;

    Check1:=TCheckBox.Create(self);
    Check1.Parent:=Form1;
    Check1.Width:=10;Check1.Height:=10;
    Check1.Left:=Form1.Left+100;
    Check1.Top:=Form1.Top+25;
    Check1.OnClick:=@SMessage;

    Check2:=TCheckBox.Create(self);
    Check2.Parent:=Form1;
    Check2.Width:=10;Check2.Height:=10;
    Check2.Left:=Form1.Left+50;
    Check2.Top:=Form1.Top+25;
    Check2.OnClick:=@SMessage;
end;

end.
                   
« Last Edit: January 30, 2012, 03:32:07 am by IndianaJones »

Martin_fr

  • Hero Member
  • *****
  • Posts: 1218
Re: Error: Security raised exception class 'External:SIGSEGV'.
« Reply #5 on: January 30, 2012, 02:41:40 am »
Code: [Select]

procedure TForm1.LazarusClick(Sender: TObject);
begin
   CC.Enabled := False;
  Microsoft. Enabled := False;
  Delphi.Enabled := False ;
end;

 begin
  If Lazarus.Checked and Pascal.Checked and DSOD.Checked and RSS.Checked and III.Checked then Exit;

end.
           

In your paste, the procedure TForm1.LazarusClick ends. And then comes a begin and your code.

that means it runs when the app initializes. The objects do not exist then...

---
do you see those?
http://wiki.lazarus.freepascal.org/New_IDE_features_since#divider_lines_in_editor

they tell you where the procedure ends...

And also
http://wiki.lazarus.freepascal.org/New_IDE_features_since#block_matching

Martin_fr

  • Hero Member
  • *****
  • Posts: 1218
Re: Error: Security raised exception class 'External:SIGSEGV'.
« Reply #6 on: January 30, 2012, 02:44:13 am »

If you define any object in the var section you have to create it dynamically so you dont need to declare those variables in the var section. Also you dont need to define 'begin' at the end of the program.

ups I did not see the 2nd list of variables.
but he would have needed them, as init can not access the fields in the form

IndianaJones

  • Sr. Member
  • ****
  • Posts: 408
Re: Error: Security raised exception class 'External:SIGSEGV'.
« Reply #7 on: January 30, 2012, 02:58:12 am »
Upps, I missed one thing, if you create objects dynamically you have to free them before closing the application. (free or freeandnil)
Like this:

Check1.Free;Check2.Free;

Yes Martin, right.
« Last Edit: January 30, 2012, 03:07:31 am by IndianaJones »

mundim

  • New member
  • *
  • Posts: 11
Re: Error: Security raised exception class 'External:SIGSEGV'.
« Reply #8 on: January 30, 2012, 09:00:13 pm »
Hi, thanks for helping but I must say I didn't understand almost anything of these lasts posts... Sorry for being so slow...

If you could explain again, more detailed, I would be grateful, again thanks for helping...

IndianaJones

  • Sr. Member
  • ****
  • Posts: 408
Re: Error: Security raised exception class 'External:SIGSEGV'.
« Reply #9 on: January 31, 2012, 09:24:03 am »

For good tutorials about oop programming, please look at this link to get information about the base.
http://pp4s.co.uk/index.html
Thats a very fine site and gives examples alot. Then specify which part you really dont understand.
Thanks.

mundim

  • New member
  • *
  • Posts: 11
Re: Error: Security raised exception class 'External:SIGSEGV'.
« Reply #10 on: January 31, 2012, 03:16:14 pm »
The part that would solve my problem with my program...  :-\

Martin_fr

  • Hero Member
  • *****
  • Posts: 1218
Re: Error: Security raised exception class 'External:SIGSEGV'.
« Reply #11 on: January 31, 2012, 06:14:14 pm »
Well, lets see:

you created a copy of
Code: [Select]
  CC: TCheckBox;
    IV: TCheckBox;
...
in a new var section?

Why?

1)
If the answer is, because it did give an error about  "CC not found" when you tried to compile, then do you know, why you got that error?

If not, then you need to read about OO first. You need to know the difference between a method and a procedure.
If you do not, you will get plenty more problems like this...

2)
If other reasons, then why.

---------------
help us understanding how you got to the code you have (why you did things) and then we can help you.

If we do not know what you did not understand, we can't help.

----------------
Also, when you declared those variables, what did you expect to happen?  If I guess, you want them to be the TChecbok. But how did you expect them to get that value.

Hint again:
A TCheckbox is an object. The field / class-variable (read about OO to understand) is set to the object (that is done by Lazarus for you)

You need to read up on tutorials, what happens, if variables in different locations, have the same name. (local variables, global var, class var, ...)

Then you should be able to understand.

---------
Also you never reacted: why an initialization section (begin end after last procedure)?




Martin_fr

  • Hero Member
  • *****
  • Posts: 1218
Re: Error: Security raised exception class 'External:SIGSEGV'.
« Reply #12 on: January 31, 2012, 06:20:39 pm »
One more thing:

"CC" is not the checkbox.

It is the name of a field (class variable) containing the checkbox.

This is a new/second variable
var
  CC: TCheckbox

mundim

  • New member
  • *
  • Posts: 11
Re: Error: Security raised exception class 'External:SIGSEGV'.
« Reply #13 on: January 31, 2012, 08:53:11 pm »
I don't, Lazarus added those variables, I think, it wasn't me, if I take them out the program compils exactly like it did earlier but now when I add that last line of code that I'm trying to get right it doesn't identify the CheckBox1,CheckBox5,CheckBox11, etc...

"New" code:
Code: [Select]
unit Unit1;

{$mode objfpc}{$H+}

interface

uses
  Classes, SysUtils, FileUtil, Forms, Controls, Graphics, Dialogs, StdCtrls;

type

  { TForm1 }

  TForm1 = class(TForm)
    CC: TCheckBox;
    IV: TCheckBox;
    II: TCheckBox;
    V: TCheckBox;
    III: TCheckBox;
    Label6: TLabel;
    RSS: TCheckBox;
    GFD: TCheckBox;
    SAP: TCheckBox;
    SoWL: TCheckBox;
    Label5: TLabel;
    SoT: TCheckBox;
    DSOD: TCheckBox;
    SuAP: TCheckBox;
    KBT: TCheckBox;
    Java: TCheckBox;
    CSS: TCheckBox;
    HTML: TCheckBox;
    Label4: TLabel;
    Pascal: TCheckBox;
    Lazarus: TCheckBox;
    Delphi: TCheckBox;
    Microsoft: TCheckBox;
    Label1: TLabel;
    Label2: TLabel;
    Label3: TLabel;
    procedure CCClick(Sender: TObject);
    procedure CSSClick(Sender: TObject);
    procedure DelphiClick(Sender: TObject);
    procedure DSODClick(Sender: TObject);
    procedure GFDClick(Sender: TObject);
    procedure HTMLClick(Sender: TObject);
    procedure IIClick(Sender: TObject);
    procedure IIIClick(Sender: TObject);
    procedure IVClick(Sender: TObject);
    procedure JavaClick(Sender: TObject);
    procedure KBTClick(Sender: TObject);
    procedure LazarusClick(Sender: TObject);
    procedure MicrosoftClick(Sender: TObject);
    procedure PascalClick(Sender: TObject);
    procedure RSSClick(Sender: TObject);
    procedure SAPClick(Sender: TObject);
    procedure SoTClick(Sender: TObject);
    procedure SoWLClick(Sender: TObject);
    procedure SuAPClick(Sender: TObject);
    procedure VClick(Sender: TObject);



  private
    { private declarations }
  public
    { public declarations }
  end;

 var
 Form1: TForm1;




 Implementation

{$R *.lfm}

{ TForm1 }













procedure TForm1.MicrosoftClick(Sender: TObject);
begin
  CC.Enabled := False;
  Lazarus.Enabled := False ;
  Delphi.Enabled := False ;
end;

procedure TForm1.PascalClick(Sender: TObject);
begin
  HTML.Enabled :=False  ;
  CSS.Enabled := False ;
  Java.Enabled := False  ;
end;

procedure TForm1.RSSClick(Sender: TObject);
begin
  GFD.Enabled := False;
  SAP.Enabled := False;
  SoWL.Enabled := False  ;
end;

procedure TForm1.SAPClick(Sender: TObject);
begin
  GFD.Enabled := False ;
  RSS.Enabled := False   ;
  SoWL.Enabled := False   ;

end;

procedure TForm1.SoTClick(Sender: TObject);
begin
  DSOD.Enabled := False ;
  KBT.Enabled := False   ;
  SuAP.Enabled := False  ;
end;

procedure TForm1.SoWLClick(Sender: TObject);
begin
  RSS.Enabled := False;
  SAP.Enabled := False ;
  GFD.Enabled := False ;
end;

procedure TForm1.SuAPClick(Sender: TObject);
begin
  SoT.Enabled := False ;
  DSOD.Enabled := False ;
  KBT.Enabled := False  ;
end;

procedure TForm1.VClick(Sender: TObject);
begin
  III.Enabled := False  ;
  II.Enabled := False    ;
  IV. Enabled := False    ;
end;

procedure TForm1.DelphiClick(Sender: TObject);
begin
  CC.Enabled := False;
  Lazarus. Enabled := False;
  Microsoft. Enabled := False;
end;

procedure TForm1.DSODClick(Sender: TObject);
begin
  SoT.Enabled := False;
  SuAP.Enabled := False;
  KBT.Enabled := False;

end;







procedure TForm1.GFDClick(Sender: TObject);
begin
  SoWL.Enabled := False ;
  RSS.Enabled := False  ;
  SAP.Enabled := False  ;
end;

procedure TForm1.HTMLClick(Sender: TObject);
begin
 CSS.Enabled := False ;
  Java.Enabled := False  ;
  Pascal.Enabled := False  ;
end;

procedure TForm1.IIClick(Sender: TObject);
begin
  V.Enabled := False   ;
  III.Enabled := False  ;
  IV.Enabled := False    ;

end;

procedure TForm1.IIIClick(Sender: TObject);
begin
  II.Enabled := False   ;
  V.Enabled := False   ;
  IV. Enabled := False;
end;

procedure TForm1.IVClick(Sender: TObject);
begin
  V.Enabled := False    ;
  III.Enabled := False ;
  II. Enabled := False;
end;

procedure TForm1.JavaClick(Sender: TObject);
begin
  Pascal.Enabled := False  ;
  CSS.Enabled := False  ;
  HTML.Enabled := False  ;
end;

procedure TForm1.KBTClick(Sender: TObject);
begin
  SuAP.Enabled := False;
  SoT.Enabled := False;
  DSOD.Enabled := False ;
end;

procedure TForm1.CCClick(Sender: TObject);
begin
   Lazarus. Enabled := False;
   Microsoft. Enabled := False;
   Delphi.Enabled := False ;
end;

procedure TForm1.CSSClick(Sender: TObject);
begin
  Java.Enabled := False  ;
  Pascal.Enabled := False  ;
  HTML.Enabled := False  ;
end;

procedure TForm1.LazarusClick(Sender: TObject);
begin
   CC.Enabled := False;
  Microsoft. Enabled := False;
  Delphi.Enabled := False ;
end;
 begin
 If Lazarus.Checked and Pascal.Checked and DSOD.Checked and RSS.Checked and III.Checked then Exit;
end.
     

Now not compiling because it gives error that can't identify "Lazarus, Pascal, DSOD...  on the last line of coding"...

And regarding the begin, I don't, ain't I suppose to put begin and end to separate things? If I take the "begin" out, there's an error when compiling "Begin expected, If found"...

And thanks for the guides, I'll read those...


And sorry if I really should have said it in the begginning, but the program in not actually a program, is an application... I don't know if that changes a lot of things...
« Last Edit: January 31, 2012, 09:02:49 pm by mundim »

Martin_fr

  • Hero Member
  • *****
  • Posts: 1218
Re: Error: Security raised exception class 'External:SIGSEGV'.
« Reply #14 on: January 31, 2012, 09:12:25 pm »
Those where put by Lazarus
Code: [Select]
TForm1 = class(TForm)
    CC: TCheckBox;
    IV: TCheckBox;
    II: TCheckBox;
    V: TCheckBox;
and Lazarus takes care they are initialized, so they can be used to access the CheckBoxes.

This too comes from Lazarus
Code: [Select]
var
  Form1: TForm1;


Those were definitely NOT put there by Lazarus
Code: [Select]
var
  CC: TCheckBox;
    IV: TCheckBox;
    II: TCheckBox;
    V: TCheckBox;
    III: TCheckBox;

Quote
And regarding the begin, I don't, ain't I suppose to put begin and end to separate things? If I take the "begin" out, there's an error when compiling "Begin expected, If found"...

Yes you can put begin end in your code. But the way you did, is not the way you wanted.

I pointed you to 2 tools helping you to find matching pairs of begin end.
( Because frankly spoken: I do not think you did. )

If you followed them, you should have spotted that the last begin is outside of any procedure (behind/after the last procedure.

- Did you really want to write code outside of any procedure ?
- Do you know what such code means ?


 

Recent

Get Lazarus at SourceForge.net. Fast, secure and Free Open Source software downloads