Bookstore

Recent

Author Topic: Error: Project raised exception class 'External:SIGSEGV'.  (Read 196044 times)

OttoMan28

  • New member
  • *
  • Posts: 5
Re: Error: Project raised exception class 'External:SIGSEGV'.
« Reply #75 on: May 14, 2016, 08:50:46 pm »
I'm sad to say, its also there in 1.6.0 - I just ran into also.
Will give the error on a simple form with just a button or so.
However the .exe will work fine.

Any suggestions ?

I'm using a Win7, 64 bit
Old Compass/Poly Pascal guy, climbing the learning curve of Lazarus :-/
So n00bs questions might follow...

OttoMan28

  • New member
  • *
  • Posts: 5
Re: Error: Project raised exception class 'External:SIGSEGV'.
« Reply #76 on: May 14, 2016, 10:40:35 pm »
Well, a reinstall of Lazarus removed the problem.  :o
That is comforting ... not.
Old Compass/Poly Pascal guy, climbing the learning curve of Lazarus :-/
So n00bs questions might follow...

BMUN1

  • Newbie
  • Posts: 3
Re: Error: Project raised exception class 'External:SIGSEGV'.
« Reply #77 on: June 12, 2016, 03:19:29 am »
Hi guys,

I have Laz 1.6 on W10x64 using MSSQL 2008 r2 DB and I still consistently get SIGSEGV error at runtime (from IDE or external exe) with any data control that is clicked on or attempting to nav a dataset. Appears to be on dataChange event (tried both TDBGrid and TDBNavigator separately and together)

Holding out for a hero...

ezlage

  • Sr. Member
  • ****
  • Posts: 305
  • (Silêncio)
    • Lageteck
« Last Edit: June 12, 2016, 05:15:11 am by ezlage »
Sorry by my poor english.

Atenciosamente,

Ezequiel Lage
ezequiel@lageteck.com

https://github.com/ezlage

BMUN1

  • Newbie
  • Posts: 3
Re: Error: Project raised exception class 'External:SIGSEGV'.
« Reply #79 on: June 13, 2016, 02:22:57 am »
Thanks friend. I don't know if resetting debugger to alt GDB fixed it or the 5 reinstalls did but in the end my only problem was a bunch of package compiles erroring on files not found. I just copied the files it couldn't find to the units dir and now everything works. Thanks again!

pixelink

  • Hero Member
  • *****
  • Posts: 1181
    • Pixelink Software
Re: Error: Project raised exception class 'External:SIGSEGV'.
« Reply #80 on: August 21, 2016, 12:40:09 pm »
I got the same error 'External SIGSEGV' today....

And what I did was so simple to do to fix it. (the docs mention string problems in DLL's)

I replaced "string' with PChar (this is for Windows machines)

THE DLL:
Code: Pascal  [Select]
  1. Function getMsg():String; stdcall;
  2.  
  3. to
  4.  
  5. Function getMsg():PChar; stdcall;
  6.  

THE APP:
Code: Pascal  [Select]
  1. type
  2.   TMyDLL = function(): String; stdcall;
  3.  
  4. to
  5.  
  6. type
  7.   TMyDLL = function(): PChar; stdcall;
  8.  
Can't Type - Forgetful - Had Stroke = Forgive this old man!

Pixelink Software
LAZ 2.02 •  VSSTUDIO(.Net) 2019 • Win10 • 16G RAM • Nivida GForce RTX 2060

Akira1364

  • Hero Member
  • *****
  • Posts: 540
Re: Error: Project raised exception class 'External:SIGSEGV'.
« Reply #81 on: August 21, 2016, 04:53:36 pm »
Regarding GDB in general, I've found that the builds of 7.9 available here work very well with Lazarus:
http://www.equation.com/servlet/equation.cmd?fa=gdb

steve.huang

  • Newbie
  • Posts: 3
Re: Error: Project raised exception class 'External:SIGSEGV'.
« Reply #82 on: October 24, 2016, 10:09:54 am »
I got the same error 'External SIGSEGV' today....

And what I did was so simple to do to fix it. (the docs mention string problems in DLL's)

I replaced "string' with PChar (this is for Windows machines)

THE DLL:
Code: Pascal  [Select]
  1. Function getMsg():String; stdcall;
  2.  
  3. to
  4.  
  5. Function getMsg():PChar; stdcall;
  6.  

THE APP:
Code: Pascal  [Select]
  1. type
  2.   TMyDLL = function(): String; stdcall;
  3.  
  4. to
  5.  
  6. type
  7.   TMyDLL = function(): PChar; stdcall;
  8.  
I did it follow your suggestion,but got a wrong return result when I try to convert the PChar to string with StrPas()

Thaddy

  • Hero Member
  • *****
  • Posts: 9782
Re: Error: Project raised exception class 'External:SIGSEGV'.
« Reply #83 on: October 24, 2016, 10:16:40 am »
StrPas is old school. Assign the PChar to a string like so. string := pchar;
The compiler will do that for you if the PChar is correct and valid in the first place.
Code: Pascal  [Select]
  1. function gimmeastring(const a:pchar):string;inline;  // this is supposed to do what strpas does ;) Make a copy, refcounted.
  2. begin
  3.   result := a;
  4. end;

Or better:
Code: Pascal  [Select]
  1. var
  2.   a:PChar;
  3.   b:string;
  4. begin
  5.   b := a;
  6. end.
   

If that does not work you wrote wrong code. Simple as that.
« Last Edit: October 24, 2016, 10:27:51 am by Thaddy »
I am more like donkey than shrek

steve.huang

  • Newbie
  • Posts: 3
Re: Error: Project raised exception class 'External:SIGSEGV'.
« Reply #84 on: October 25, 2016, 06:29:08 am »
Code: Pascal  [Select]
  1. library mydll;
  2.  
  3. {$mode objfpc}{$H+}
  4.  
  5. uses
  6.   Classes, SysUtils, Windows
  7.   { you can add units after this };
  8. function myMessage(): string; stdcall;
  9.   begin
  10.      MessageBox(0,PChar('Hello world'),PChar(''),MB_OK);
  11.    end;
  12.  
  13. Function WinUserName(): PChar; stdcall;
  14. var
  15.    FStr: PChar;
  16.    FSize: Cardinal;
  17. begin
  18.    FSize := 255;
  19.    GetMem(FStr, FSize);
  20.    Windows.GetUserName(FStr, FSize);
  21.    Result :=FStr;
  22.    FreeMem(FStr);
  23. end;
  24.  
  25.  
  26. exports
  27.    myMessage,WinUserName;
  28.  
  29.  
  30. end.                              
  31.  

Code: Pascal  [Select]
  1. procedure TForm1.BitBtn1Click(Sender: TObject);
  2. var
  3.   MyHandle: TLibHandle;
  4.   MyDLL: TMyDLL;
  5.   userId: string;
  6.  MyHandle := LoadLibrary('mydll.dll');
  7.   if MyHandle<>0 then
  8.     begin
  9.       pointer(MyDLL):=getProcedureAddress(Myhandle,'WinUserName');
  10.       if Assigned(MyDLL) then
  11.         begin
  12.           userid:=MyDLL();
  13.           edit2.text:=userid;
  14.         end;
  15.     end    
  16.  
The same wrong return result as StrPas

Cyrax

  • Hero Member
  • *****
  • Posts: 790
Re: Error: Project raised exception class 'External:SIGSEGV'.
« Reply #85 on: October 25, 2016, 10:51:35 am »
Code: Pascal  [Select]
  1. library mydll;
  2.  
  3. {$mode objfpc}{$H+}
  4.  
  5. uses
  6.   Classes, SysUtils, Windows
  7.   { you can add units after this };
  8. function myMessage(): string; stdcall;
  9.   begin
  10.      MessageBox(0,PChar('Hello world'),PChar(''),MB_OK);
  11.    end;
  12.  
  13. Function WinUserName(): PChar; stdcall;
  14. var
  15.    FStr: PChar;
  16.    FSize: Cardinal;
  17. begin
  18.    FSize := 255;
  19.    GetMem(FStr, FSize);
  20.    Windows.GetUserName(FStr, FSize);
  21.    Result :=FStr;
  22.    FreeMem(FStr)
  23. end;
  24. ...
  25.  
...

Remove FreeMem(FStr) and do your cleaning up (freeing memory etc.) in your main code.

steve.huang

  • Newbie
  • Posts: 3
Re: Error: Project raised exception class 'External:SIGSEGV'.
« Reply #86 on: October 25, 2016, 11:10:53 am »
Code: Pascal  [Select]
  1. library mydll;
  2.  
  3. {$mode objfpc}{$H+}
  4.  
  5. uses
  6.   Classes, SysUtils, Windows
  7.   { you can add units after this };
  8. function myMessage(): string; stdcall;
  9.   begin
  10.      MessageBox(0,PChar('Hello world'),PChar(''),MB_OK);
  11.    end;
  12.  
  13. Function WinUserName(): PChar; stdcall;
  14. var
  15.    FStr: PChar;
  16.    FSize: Cardinal;
  17. begin
  18.    FSize := 255;
  19.    GetMem(FStr, FSize);
  20.    Windows.GetUserName(FStr, FSize);
  21.    Result :=FStr;
  22.    FreeMem(FStr)
  23. end;
  24. ...
  25.  
...

Remove FreeMem(FStr) and do your cleaning up (freeing memory etc.) in your main code.
Write sample code here please!