Recent

Author Topic: ShowMessage causes External SIGSEGV?  (Read 14241 times)

Ramijami

  • Jr. Member
  • **
  • Posts: 87
ShowMessage causes External SIGSEGV?
« on: May 20, 2014, 03:03:23 pm »
Need some help again please.

I get an error message:

Project raised exception class 'External: SIGSEGV'.

In file '.include\custimform.inc' at line 176


whenever I press a button that has a "ShowMessage". This happened after I installed the newer version of Lazarus/freepascal, with no problems on the older version before this, but now I get the same message on the older version (on a different PC) as well. It then takes me to the 'Customform.inc' window and points to the line (in bold-italics). This is the section:

{------------------------------------------------------------------------------
  Method: TCustomForm.BeforeDestruction
  Params:  None
  Returns: Nothing

  Gets called before the destruction of the object
 ------------------------------------------------------------------------------}
procedure TCustomForm.BeforeDestruction;
begin
  // set csDestroying
  inherited BeforeDestruction;
  //debugln(['TCustomForm.BeforeDestruction ',DbgSName(Self),' ',csDestroying in ComponentState]);
  // EndWrite will happen in the destructor
Line 176)))))) GlobalNameSpace.BeginWrite;
  Screen.FSaveFocusedList.Remove(Self);
  RemoveFixupReferences(Self, '');
  if FormStyle <> fsMDIChild then Hide;
  DoDestroy;
  // don't call the inherited method because it calls Destroying which is already called
end;

This only happens after I have run the programme at least once, but the programme runs without errors and only stops when I press a button containing a 'ShowMessage', and crashes after I pres "Ok". If I press the buttons and the the 'ShowMessage' pops-up before I have run the programme once, the programme runs without crashing. Is there a setting in debugger or anything else I need to look at? A search on the forum hasn't given any clues.

I'm using Windows 7 64 bit on one PC, and Windows 7 32 Bit on the other PC, so am using the latest 32 bit Lazarus/freepascal version 1.2.2/FPC 2.6.4. Any points in the right direction would be appreciated.

Thanks

typo

  • Hero Member
  • *****
  • Posts: 3051
Re: ShowMessage causes External SIGSEGV?
« Reply #1 on: May 20, 2014, 04:05:45 pm »
Probably this code is being edited by the developers. Try to use some previous version of Lazarus (one that still does not have this issue).

Ramijami

  • Jr. Member
  • **
  • Posts: 87
Re: ShowMessage causes External SIGSEGV?
« Reply #2 on: May 21, 2014, 04:28:20 pm »
Thanks for the response typo. Tried it with previous older versions as suggested and get the same result so seems to be something else rather than the version I'm using.

Mike.Cornflake

  • Hero Member
  • *****
  • Posts: 1269
Re: ShowMessage causes External SIGSEGV?
« Reply #3 on: May 21, 2014, 05:52:11 pm »
@Ramijami:
I've just created a new blank project.  Dropped a button on a form.  In the onclick I called ShowMessage('Hello World');
No matter how many times I click the button, I experience no problems.
I did this with Lazarus 1.2/FPC 2.6.2 - so, not an exact match to your setup :-( Though I am also Win 7/32 bit Laz.  Unfortunately I don't have 1.2.2 with me...

Could you try the above steps with your setup? 

I suspect we'll find that the issue is not with ShowMessage, but with some code of yours.  If so, can you post snippets of code around your call to ShowMessage?  We'll see what's happening and hopefully advise.  If you can't post your own code (confidentiality issues), then could you try creating a simple project of your own that reproduces the issue?
Lazarus Trunk/FPC latest fixes on Windows 11
  I'm getting old and stale.  Slowly getting used to git, I'll get there...

typo

  • Hero Member
  • *****
  • Posts: 3051
Re: ShowMessage causes External SIGSEGV?
« Reply #4 on: May 21, 2014, 06:33:42 pm »
I have just downloaded and installed the latest version of Lazarus for 32bit and created the same button on a form. It is OK, no problems.
« Last Edit: May 21, 2014, 06:54:23 pm by typo »

Ramijami

  • Jr. Member
  • **
  • Posts: 87
Re: ShowMessage causes External SIGSEGV?
« Reply #5 on: May 23, 2014, 12:28:33 pm »
Tx guys.......re-installed the latest version and the external SIGSEGV message appears with error at address 41E3DC, but instead of the error pointing to customform.inc, the assembler window now pops up. I have no clue how to interpret the error messages but this is the line: "0041E3DC 8b12 mov(%edx),%edx". I've also noticed that it's not just the ShowMessages but when I press my exit button as well. Here is some sample code for one of my Showmessages:

Code: [Select]
if (FDNumBank.checked=True) and (FDNumSelected=0) then
begin
ShowMessage('Please fill in OR Deactivate FDNumB!!!');
exit;
end;

and the code for my exit button:
Code: [Select]
procedure TForm1.Button10Click(Sender: TObject);
begin
  Close;   //Application.Terminate;
end;

These two pieces of code I use in a duplicate program with no problems so I'm stumped as to why it's happening in this one. I'm sure it's probably something I did/changed but don't know where to look.

howardpc

  • Hero Member
  • *****
  • Posts: 4144
Re: ShowMessage causes External SIGSEGV?
« Reply #6 on: May 23, 2014, 01:14:48 pm »
Code snippets such as these are no help to remote debuggers.
You would have to share the entire code of your project (or a cut-down version that reliably demonstrates the problem you encounter).

Ramijami

  • Jr. Member
  • **
  • Posts: 87
Re: ShowMessage causes External SIGSEGV?
« Reply #7 on: May 23, 2014, 02:59:15 pm »
Tx for the the response howardpc..........unfortunately my programme is quite large and I haven't been able to replicate this problem with a cut down version. An older version (about a month old) doesn't produce the problem, and removing the additions (that I remember) between the older version and the current version didn't help as the problem remains. I am convinced it is something I did when adding something at some stage, so now it's just a matter of finding out what. Other than that the programme runs without errors  :)

taazz

  • Hero Member
  • *****
  • Posts: 5368
Re: ShowMessage causes External SIGSEGV?
« Reply #8 on: May 23, 2014, 03:11:27 pm »
diff the files pas & lfm to find the differences, if that does not help then try to recreate the form and add functionality one piece at a time to see where it will fail. If it does not fail then it might be corrupted file or something through away the old form/unit and keep the reconstructed one.
Good judgement is the result of experience … Experience is the result of bad judgement.

OS : Windows 7 64 bit
Laz: Lazarus 1.4.4 FPC 2.6.4 i386-win32-win32/win64

Duvel

  • Newbie
  • Posts: 6
Re: ShowMessage causes External SIGSEGV?
« Reply #9 on: January 16, 2015, 02:21:49 pm »
Got the exact same issue. The program runs mooth as shit off a duck's ass with the code bellow BUT! when I change "x := 0" and "x:= 1" by "Showmessage('good)" and "showmessage('bad)" then the error described above occure. Very strange!

grtz,
T

type

  { TForm1 }

  TForm1 = class(TForm)
    Button1: TButton;
    procedure Button1Click(Sender: TObject);
  private
    {private declarations}
      Chandle_: Thandle;

  public
    { public declarations }
  const
       ipadr_: pchar = '192.168.1.222';
       port_:word = 502;
       UseTCP_:longbool= FALSE;
       ReqTime_:longword = 1000;

  end;

var
  Form1: TForm1;
  ret: integer;
  x: integer;
implementation

{$R *.lfm}

{ TForm1 }

function MBTInit():integer;cdecl;external 'MBT.dll';
{function MBTConnect(Pchar('192.168.1.222');port:word;UseTCP:LongBool;ReqTime:longword;Chandle:Thandle):Longword;cdecl;external 'MBT.dll';}
function MBTConnect(adr:pchar;port:word;UseTCP:longbool;ReqTime:longword;var Chandle:Thandle):integer;cdecl;external 'MBT.dll';
procedure TForm1.Button1Click(Sender: TObject);
begin
     if MBTInit() = 0 then
        begin
             ret := MBTConnect(ipadr_,port_,UseTCP_,ReqTime_,Chandle_);
             if ret = 0 then
                begin
                     x:=1;
                end
             else
                 begin
                   x:=0;
                 end
        end;
end; 

marcov

  • Administrator
  • Hero Member
  • *
  • Posts: 12715
  • FPC developer.
Re: ShowMessage causes External SIGSEGV?
« Reply #10 on: January 16, 2015, 03:33:52 pm »
So probably your calls to mbt* corrupt the stack. Check definitions again and again, try stdcall etc.

Duvel

  • Newbie
  • Posts: 6
Re: ShowMessage causes External SIGSEGV?
« Reply #11 on: January 17, 2015, 12:53:47 am »
Indeed.  stdcall fixed it.
Thx. :)

Zath

  • Sr. Member
  • ****
  • Posts: 391
Re: ShowMessage causes External SIGSEGV?
« Reply #12 on: April 14, 2015, 06:09:47 pm »
Indeed.  stdcall fixed it.
Thx. :)

Can you explain this please ?
I'm just doodling with D7 and trying on Lazarus and get the same issues.

Thanks



V 1.2.6 / 2.64 (46529) Win 7
« Last Edit: April 14, 2015, 06:39:24 pm by Zath »

howardpc

  • Hero Member
  • *****
  • Posts: 4144
Re: ShowMessage causes External SIGSEGV?
« Reply #13 on: April 14, 2015, 08:10:09 pm »
Don't automatically blame ShowMessage(). It's not the only call you made.
Most likely a problem not with ShowMessage() but with GetIEVersion() - what is the code for that function?
Do you have range checking turned on?
What does Debugln(GetIEVersion('Version')[1]); produce - also a memory access error?

Zath

  • Sr. Member
  • ****
  • Posts: 391
Re: ShowMessage causes External SIGSEGV?
« Reply #14 on: April 15, 2015, 11:41:48 am »
Don't automatically blame ShowMessage(). It's not the only call you made.
Most likely a problem not with ShowMessage() but with GetIEVersion() - what is the code for that function?
Do you have range checking turned on?
What does Debugln(GetIEVersion('Version')[1]); produce - also a memory access error?

The whole code was one of Torry's Delphi snippets. It worked "Out of the box" with the old Delphi 7.
I just thought I'd see how it faired in Lazarus.
The code below is the GETIEVersion.

Code: [Select]
function GetIEVersion(Key: string): string;
var
   Reg: TRegistry;
begin
   Reg := TRegistry.Create;
   try
     Reg.RootKey := HKEY_LOCAL_MACHINE;
     Reg.OpenKey('Software\Microsoft\Internet Explorer', False);
     try
       Result := Reg.ReadString(Key);
     except
       Result := '';
     end;
     Reg.CloseKey;
   finally
     Reg.Free;
   end;
end;


I've just changed the showmessage to a "Hello World" and it works fine.
So good call on the GETIE bit. I just saw the same error and jumped in.

« Last Edit: April 15, 2015, 11:52:35 am by Zath »

 

TinyPortal © 2005-2018