Lazarus

Programming => General => Topic started by: SA.Blackmon on November 28, 2020, 03:45:42 am

Title: From Form_Tutorial#The_First_GUI_Application: raised exception 'External SIGSEGV
Post by: SA.Blackmon on November 28, 2020, 03:45:42 am
I am recent to Lazarus but have been doing Pascal (40 years) and Delphi (25 years) and this is a little bit irritating.
I was having an issue (as above) so I decided to do the tutorial and got the same exception thrown.
With the lpr creating the two forms, I was successful with doing both Show and ShowModal.
But, when doing the form creation (..._main.pas), an error is thrown on either the Show or the ShowModal.

I have read a number of posts (25 or so) about different ways to throw the 'External SIGSEGV' exception but found
none that fit my situation.

Please help!!

Title: Re: From Form_Tutorial#The_First_GUI_Application: raised exception 'External SIGSEGV
Post by: Handoko on November 28, 2020, 04:01:17 am
Hello SA.Blackmon,
Welcome to the forum.

Please provide the whole project, so we can test it. If you are not willing to publicize the whole project you can write a demo that shows the issue.

You can manually compress all the files (except: binaries and backup folder) or use the built-in tool, and attach the zip file to the forum.
Lazarus main menu > Project > Publish Project
Title: Re: From Form_Tutorial#The_First_GUI_Application: raised exception 'External SIGSEGV
Post by: PascalDragon on November 28, 2020, 11:18:04 am
Judging from the thread title I assume that SA.Blackmon means this (https://wiki.freepascal.org/Form_Tutorial#The_First_GUI_Application) tutorial.
Title: Re: From Form_Tutorial#The_First_GUI_Application: raised exception 'External SIGSEGV
Post by: SA.Blackmon on November 28, 2020, 01:23:51 pm
I apologize. I clearly have little idea of how this site works.

All my source is in the attachment named TestCallingForms_stuff.pas.

PascalDragon was correct in the assumption regarding the tutorial.
Title: Re: From Form_Tutorial#The_First_GUI_Application: raised exception 'External SIGSEGV
Post by: SA.Blackmon on November 28, 2020, 01:58:49 pm
I have now reloaded Lazarus. I get the same results as before.
Title: Re: From Form_Tutorial#The_First_GUI_Application: raised exception 'External SIGSEGV
Post by: wp on November 28, 2020, 02:04:46 pm
I apologize. I clearly have little idea of how this site works.
Go to the folder in which you stored your project. Add the .lpr, lpi, .pas and .lfm files to a common zip. Then, for posting, open the forum editor and click on "Attachments and other options" below the editor. Click on "Attach" and use the browse button to navigate to the created zip. Then click "Post". This will upload the compilable project for us to see what's wrong.
Title: Re: From Form_Tutorial#The_First_GUI_Application: raised exception 'External SIGSEGV
Post by: SA.Blackmon on November 28, 2020, 03:40:57 pm
I have added the zip file.

I found a serious beginner's mistake. I failed to create the third form.***

Now, I am getting a heap dump after I close the app either from within the debugger or running the executable.

*** My change to the code was in testcallingforms_01.pas

procedure TForm2.Button1Click(Sender: TObject);
begin
  Form3 := TForm3.Create(nil);
  try
    Form3.Showmodal;

  finally
    Form3.Free;
  end;
end;
Title: Re: From Form_Tutorial#The_First_GUI_Application: raised exception 'External SIGSEGV
Post by: Handoko on November 28, 2020, 04:12:36 pm
This should solve your problem:

Code: Pascal  [Select][+][-]
  1. procedure TForm2.Button1Click(Sender: TObject);
  2. begin
  3.   Form3 := TForm3.Create(Self);
  4.   Form3.Show;
  5. end;

Alternatively:

If you do not know how to manually handle form creation, you should use autocreate form feature:
Lazarus main menu > Project > Project Options > left panel > Project Options > Forms

For your information, if you create a new form by using File > New > Module > Form, the newly created form will use autocreate form feature.
Title: Re: From Form_Tutorial#The_First_GUI_Application: raised exception 'External SIGSEGV
Post by: wp on November 28, 2020, 04:17:12 pm
I have added the zip file.
This is the second time that you say you attached a file, but still I don't see one...
Title: Re: From Form_Tutorial#The_First_GUI_Application: raised exception 'External SIGSEGV
Post by: Handoko on November 28, 2020, 04:23:24 pm
It is on the first post.
Title: Re: From Form_Tutorial#The_First_GUI_Application: raised exception 'External SIGSEGV
Post by: lucamar on November 28, 2020, 04:25:21 pm
I apologize. I clearly have little idea of how this site works.

For a few tips (like using CODE tags), look in the wiki, page: Forum (https://wiki.freepascal.org/Forum)  :)
Title: Re: From Form_Tutorial#The_First_GUI_Application: raised exception 'External SIGSEGV
Post by: SA.Blackmon on November 28, 2020, 05:15:59 pm
Thank you very much for the help.

I made some rookie mistakes and should never have started this thread. For all it's worth, I'd like to see the thread thrust into oblivion.

Again, thank you all for your help; it is much appreciated.

Sorry to have wasted your time.
Title: Re: From Form_Tutorial#The_First_GUI_Application: raised exception 'External SIGSEGV
Post by: PascalDragon on November 28, 2020, 05:32:41 pm
I made some rookie mistakes and should never have started this thread. For all it's worth, I'd like to see the thread thrust into oblivion.

Don't apologize for asking. You're a beginner (we all were in the past) and sometimes talking (or in this case asking) about might already helps seeing one's own mistakes.
Title: Re: From Form_Tutorial#The_First_GUI_Application: raised exception 'External SIGSEGV
Post by: wp on November 28, 2020, 06:05:04 pm
I have added the zip file.
This is the second time that you say you attached a file, but still I don't see one...

It is on the first post.

But this is not a compilable project. SA.Blackmon, you spent a lot of time combining all thise code snippets into a single file, and I have to spend a lot of time separating them and creating the missing lfm files. And there is not lpi file with the compiler settings used. Please don't do this again: Simply pack the pas, lfm, lpi and lpr files into a common zip which you can upload - then I have everything needed to begin to help you.
Title: Re: From Form_Tutorial#The_First_GUI_Application: raised exception 'External SIGSEGV
Post by: bytebites on November 28, 2020, 06:11:04 pm
There is file TestCallingForms.zip, see last attachment.
Title: Re: From Form_Tutorial#The_First_GUI_Application: raised exception 'External SIGSEGV
Post by: wp on November 28, 2020, 06:26:24 pm
Oh sorry, I did not think that the attachment was at the first post...
Title: Re: From Form_Tutorial#The_First_GUI_Application: raised exception 'External SIGSEGV
Post by: Peter H on November 28, 2020, 09:46:18 pm
The application tries to display Form3 but Form3 was not created:
Code: Pascal  [Select][+][-]
  1. program TestCallingForms_pj;
  2.  
  3. {$mode objfpc}{$H+}
  4.  
  5. uses
  6.   {$IFDEF UNIX}{$IFDEF UseCThreads}
  7.   cthreads,
  8.   {$ENDIF}{$ENDIF}
  9.   Interfaces, // this includes the LCL widgetset
  10.   Forms,
  11.   TestCallingForms_Main, testcallingforms_01 , testcallingforms_02
  12.   { you can add units after this };
  13.  
  14. {$R *.res}
  15.  
  16. begin
  17.   RequireDerivedFormResource:=True;
  18.   Application.Scaled:=True;
  19.   Application.Initialize;
  20.   Application.CreateForm(TForm1, Form1);
  21.   //Application.CreateForm(TForm2, Form2);
  22.   //Application.CreateForm(TForm3, Form3); //<- if this is uncommented, the Sigsev doesnt occur
  23.   Application.Run;
  24. end.
  25.  

Howto find this:
Looking in Google for the access violation doesnt help.
The error message shows where the access violation occured, the file and line number.
Goto this location (while debugging) and display the Call Stack.
Look in the call stack for a procedure you wrote, see that "Form3" is accessed in this procedure.
Search for all references to Form3 and see the Form was never created.
Title: Re: From Form_Tutorial#The_First_GUI_Application: raised exception 'External SIGSEGV
Post by: HansDouwe on December 05, 2020, 03:59:03 am
Hello SA Blackmon and his helpers,

Is there a solution for this problem?
Also I'm a new user of platform Lazarus.
And also in my stiuation raised sometimes (not always) this error.
I'm also using an acer latop.
I've installed Lazarus V2.0.10 (32-bits) on Windows  10.

It look like this error is raising sometimes before the debugger starts my program.
Even if I stop the program and reset de debugger before.
When I try often enough, then suddenly the debugger starts my program again.
I don't see a system, when this error is raising and when not.
 
I don't understand why this happens and I can not find the reason of this error.

Does this look like the same problem that was discussed here?

Title: Re: From Form_Tutorial#The_First_GUI_Application: raised exception 'External SIGSEGV
Post by: HansDouwe on December 05, 2020, 04:05:17 am
Continued last post:

I'm not using forms.
Title: Re: From Form_Tutorial#The_First_GUI_Application: raised exception 'External SIGSEGV
Post by: Peter H on December 05, 2020, 10:07:43 am
@HansDouwe:
There is a common problem with Lazarus 32 Bit: If "Automatic" is choosen as type of debugging info, Lazarus chooses the "Stabs" format, which is outdated for Windows.

Goto Project/Project options/Compiler Options/Debugging in Lazarus Menu and choose "Dwarf with sets" as debugger info.
If the problem persists, more about your project must be known.
You can easily export respective "publish" your project to a zip file in Lazarus and post it here, so others can try it.
Title: Re: From Form_Tutorial#The_First_GUI_Application: raised exception 'External SIGSEGV
Post by: HansDouwe on December 05, 2020, 09:20:23 pm
Hi Peter,

You're a genius.
I've changed de debugsetting in Lazarus 32 and debugging of my programs is going perfectly now (without any probelms)
I put a lot of time into solving this problem because I thought there was a problem in my code, but I would never have found this.

You've saved me a lot of troubles and now I can work much faster.

Thank you very much.

Title: Re: From Form_Tutorial#The_First_GUI_Application: raised exception 'External SIGSEGV
Post by: Peter H on December 05, 2020, 09:33:16 pm
Glad to hear this!
I fear I am not a genius, but a rather green newbie with lazarus. (not a newbie with programming in common)
I had similar problems with debugger when I started and a friendly oldtimer here teached me this.
Maybe this should be hardcoded into lazarus, I fear, many newbies stumble upon this.

all the Best,

Peter
Title: Re: From Form_Tutorial#The_First_GUI_Application: raised exception 'External SIGSEGV
Post by: trev on December 05, 2020, 09:56:38 pm
The Wiki Windows Portal (https://wiki.freepascal.org/Portal:Windows) has plenty of useful information for using Lazarus + FPC on Windows, especially the Windows Programming Tips (https://wiki.freepascal.org/Windows_Programming_Tips) article.
TinyPortal © 2005-2018