Lazarus

Installation => Windows (32/64) => Topic started by: sclsch on January 29, 2009, 12:54:24 am

Title: Error: Project raised exception class 'External:SIGSEGV'.
Post by: sclsch on January 29, 2009, 12:54:24 am
    I am very excited that I find the Lazarus IDE. I try l open it,run and find an error. Error: Project raised exception class 'External:SIGSEGV'.
is there something wrong?
thanks.

Title: Re: Error: Project raised exception class 'External:SIGSEGV'.
Post by: Bart on January 29, 2009, 04:38:46 pm
    I am very excited that I find the Lazarus IDE. I try l open it,run and find an error. Error: Project raised exception class 'External:SIGSEGV'.
Run what?

Please give us some additional information:
What OS
32 or 64 bit
Where did you install Lazarus / fpc (in what path)

What happens if you compile, then run the executable outside the IDE

Bart
Title: Re: Error: Project raised exception class 'External:SIGSEGV'.
Post by: bucsupe on January 30, 2009, 01:35:40 pm
    I am very excited that I find the Lazarus IDE. I try l open it,run and find an error. Error: Project raised exception class 'External:SIGSEGV'.
Run what?

Please give us some additional information:
What OS
32 or 64 bit
Where did you install Lazarus / fpc (in what path)

What happens if you compile, then run the executable outside the IDE

Bart

Hi,
I have the same problem. When I run  (press F9) the project from the IDE, I get the same message.
My environment:
OS: Windows XP 32 bit
I have installed it to the default installation path, wich was recommended by the installer: c:\lazarus

Version: lazarus-0.9.26-fpc-2.2.2-win32.exe from sourceforge.

Additional information
However the IDE gives this error message when I try to run the project, it builds the exactly working exe file.

What can be the problem?
Title: Re: Error: Project raised exception class 'External:SIGSEGV'.
Post by: marfig on February 02, 2009, 03:23:24 am
Hello,

I have the same problem. And will try to provide some more information.

System: 3GB ram, Windows XP SP3, with Delphi 7 and Visual Studio 2008
Lazarus: lazarus-0.9.26-fpc-2.2.2-win32 Installed to default directory.
Installation: Full Installation.

Procedure:
- I start Lazarus.
- I press F9. Default lazarus project compiles fine. But gives error right after compilation finishes

Quote
Project raised exception class: 'External: SIGSEGV'

After clicking OK...

Quote
Execution Paused
Address: $10009631
Procedure: ??
File:

Notes:
- Often, when I dismiss the second error dialogbox, the execution stays paused. Sometimes however, the executable do fire up and the main form is displayed normally.
- Building and running externally to the IDE causes no exception and the executable performs normally.
- Any project causes this exception. I suspect something to do with the debugger.

More information:

1. Lazarus used to work fine. Error starting showing up after installing Delphi 7 or so I seem to believe. Uninstalling and doing a clean reinstall of Lazarus doesn't seem to fix the problem. I however cannot at this point try to uninstall Delphi 7 and do a clean Lazarus install to see if the error stays.

2. I remember Delphi saying something about a debugger(jit debugger?) being registered to another application and asking me if I wanted to change this... I cannot remember the exact details of this dialog box. At the time I answered Yes, do register for Delphi 7.

Hope this helps.
Title: Re: Error: Project raised exception class 'External:SIGSEGV'.
Post by: Leledumbo on February 02, 2009, 03:29:54 am
It's the debugger, something wrong with it. To make it more mysterious, only some people have the problem. The other (including me), didn't have it and everything works flawlessly. I can't figure out (until now) why. I've posted the way I setup my environment, but it doesn't seem to work for other people. In case you want to know, here it goes:
Title: Re: Error: Project raised exception class 'External:SIGSEGV'.
Post by: Martin_fr on February 02, 2009, 11:37:37 am
Lazarus uses GDB (from mingw) as debugger.

Unfortunately several (if not most/all) versions of gdb for windows have (afaik/imho) one or another flaw.

The most common case seems to be related to some leak in GDB. This will be experienced as the very first time you run/debug your application (via F9 or menu) it will work, but after that you get all sort of errors.
In this case use "reset debugger" from the "run" menu.

I do not have a list which version of GDB works better or worse or how it depends on your environment. You can always try to download another version from mingw, and see if it does the trick for you.

Good luck
Title: Re: Error: Project raised exception class 'External:SIGSEGV'.
Post by: marfig on February 02, 2009, 04:00:39 pm
It seems to be related to Comodo Firewall and would be interesting if anyone experiencing this problem and seeing this could confirm if they have this firewall program installed.

This is what is reported when I try to debug an fpc app from the command line:

Quote
Starting program: C:\Projects\laz/project1.exe                                                                                                       
[New thread 3040.0xbe8]                                                                                                                               

Program received signal SIGSEGV, Segmentation fault.                                                                                                 
0x10009631 in ?? () from C:\WINDOWS\system32\guard32.dll
Title: Re: Error: Project raised exception class 'External:SIGSEGV'.
Post by: marfig on February 02, 2009, 05:14:45 pm
And here's what I did to solve the problem.

guard32.dll seems to be used by Commodo Personal Firewall mostly by it's Defense+ component. Something I don't use personally, is disabled, but still attached the dll to all running executables. The answer is in fact a few other firewall features do use this dll. Namely, it seems, the ability Commodo has of protecting against certain malware firewall-circumvent stratagems. Again, something I don't really need since I do have an anti-virus. Fortunately, this can be undone. Probably looking in Commodo configuration. But I didn't have the patience, so:

1. I fully uninstalled Commodo
2. Reboot
3. Install Commodo back again
3.1. Do not install the anti-virus component
3.2 Do no install any firewall features (i.e. choose simple enterprise-strength firewall option when asked)

Hope this helps.
Lazarus is now running as it should.
Title: Re: Error: Project raised exception class 'External:SIGSEGV'.
Post by: bucsupe on February 03, 2009, 10:35:58 pm
Thanks the help!

I really used Comodo Firewall, and this conflict with Lazarus (gdb).
I changed Comodo Firewall to PCTools Firewall, and now running perfectly the Lazarus!

 ;)

Title: Re: Error: Project raised exception class 'External:SIGSEGV'.
Post by: Marsel on May 21, 2009, 12:34:12 am
Too I use comodo firewall. I have added lazarus.exe and gdb.exe into My Own Safe Files list, have rebooted also all have earned. (comodo ver 3.9)

Sorry, for my English...
Title: Re: Error: Project raised exception class 'External:SIGSEGV'.
Post by: SV_Janjo on October 21, 2009, 04:34:56 pm
I have the same error:
Quote
Project raised exception class: 'External: SIGSEGV'
But it appears after my program is started. Program works perfectly until it comes to command:
Quote
Image1.Picture.Graphic.Width:=Image1.Width;
Image1.Picture.Graphic.Height:=Image1.Height;
THEN program shows this error. Can somebody help?
Title: Re: Error: Project raised exception class 'External:SIGSEGV'.
Post by: EMTR on October 23, 2009, 01:43:00 pm
I have the same problem but when using a Delphi app as the host and debugging a dll which appears to complete execution correctly...

Is there another debugger to use in place of this one?!
Title: Re: Error: Project raised exception class 'External:SIGSEGV'.
Post by: Ortis on November 06, 2009, 12:57:04 pm
I teach students to work in Lazarus, because our university doesn't provide us a license for Delphi. In the classroom they generated the same bug on their machines (win XP 32 bits SP3) for 3 different progs. We used Lazarus 0.9.28.1. However for older version 0.9.24.0 there was no such a bug (but were others, so we migrated).

But at other computers all works perfectly. I suspect this bug to be in some sense due to limited user right (in other places, where bug doesn't reveal itself, all people work under administrative rights), but this is only my imho.

This bug appears in the same line allways -- never mind what is there written.

We have Kaspersky antivirus active / no firewall.
Title: Re: Error: Project raised exception class 'External:SIGSEGV'.
Post by: EMTR on November 06, 2009, 01:51:28 pm
I have full administrative rights. Teach your students either .net or java.

The error I had was purely the debugger. Run without debug and it works perfectly... Then again how am I supposed to debug my code without a debugged?? Delphi 2009...
Title: Re: Error: Project raised exception class 'External:SIGSEGV'.
Post by: picstart on November 06, 2009, 04:01:56 pm
Maybe there is an unreliable interplay between lazarus and the debugger. If you are lucky you won't have an issue. If you have issues with the debugger and SIGSEGV it might just be annoying in that it generates an initial error that if dismissed by clicking and closing windows and running again (F9) it will probably work as a debugger. The issue is can you really be sure the debugger is fully functioning after you work around the first SIGSEGV ? Is the next error reported by the debugger real or is it also to be worked around? It is particularly troubling when lazarus runs fine outside the debugger maybe its just luck and failure just hasn't had a chance to find a situation in which to occur . It maybe that this is a fundamental lazarus debugger incompatibility issue that takes some other variable like the system configuration or some other program running to expose it. Now some can write such good code that they are sure if the debugger reports an error that the debugger must be buggy. Others actually need an iron clad bug free debugger to help them.
Title: Re: Error: Project raised exception class 'External:SIGSEGV'.
Post by: Ortis on November 06, 2009, 06:00:03 pm
Thank you all, I'll try to disable debugger. However it is very sad to program without debugger.

I have full administrative rights. Teach your students either .net or java.

The error I had was purely the debugger. Run without debug and it works perfectly... Then again how am I supposed to debug my code without a debugged?? Delphi 2009...

If I could choose, I would teach them Python. I do not like Java and .NET much more. But my own preferencies are not gotton into a mind. I have students, those already know Pascal and nothing else. And I have teaching plan, where Object Pascal is mentioned. So I am to use lazarus or Delphi.
Title: Re: Error: Project raised exception class 'External:SIGSEGV'.
Post by: EMTR on November 06, 2009, 07:20:54 pm
@Picstart - The debugger is the problem I think. If I compile my dll outside lazarus - ie from the command line using FPC and then try to run it from my application then it all works - I debugged it the slow way by outputting a stringlist of all the events to a file then trawling back through the file... Interestingly all the data debugged just fine - exactly as expected - I had only made minor changes. When used with the application it was made for it works like a charm. But load up the debugger and back comes the sigsegv. It debugs fine until it exits the external call, ie, until it trys to return to the calling application.

Hope that helps.
Title: Re: Error: Project raised exception class 'External:SIGSEGV'.
Post by: Marc on November 06, 2009, 07:54:39 pm
@Ortis:
what is the problem with the debugger ? it's not clear from your message. In what case you get an error ?
It should work on XP SP3 too.
Title: Re: Error: Project raised exception class 'External:SIGSEGV'.
Post by: creatxr on November 09, 2009, 11:20:55 pm
I meet this problem also today.
I remember that it worked well yesterday.
But today, I just created a new project and run, it raised this exception.
It has no problem while compile, it raised when it runs.
So I uninstalled and reinstalled it.
But it is useless.
------------------------
environment:
e:\lazarus
windows xp
Title: Re: Error: Project raised exception class 'External:SIGSEGV'.
Post by: EMTR on November 12, 2009, 04:08:30 pm
OOOOK - I've just been dragged back into this project at the office.

Background...

I have a Delphi 2009 Exe.

I have a Lazarus DLL compiled with FPC.

I need to compile the dll using fpc. Its basically some rules that a customer provides and then the exe compiles its own dll and loads it. Its more complex than that but thats the essence of it. If I build everything in Delphi (DLL and EXE) then it all works :) Hurray! If I build everything in Lazarus (DLL and test harness exe) it all works :) Hurray!

If I go back to building my EXE in Delphi 2009 and the DLL in Lazarus I get 'External Sigsegv'... I think its doing the equivalent of an Access Violation somewhere but I can't see it... I'm currently working on solving the problem on the assumption that its some problem with Unicode / AnsiString / String and PChar. I can't debug it - Lazarus refuses to step into the dll when I specify the application as the host otherwise I might actually get somewhere... Not sure if this snippet of info will help or not...?
Title: Re: Error: Project raised exception class 'External:SIGSEGV'.
Post by: theo on November 12, 2009, 04:52:13 pm
Afaik, you have to interface the DLL in this case as if you would call it from C.
So no String only PChar etc.
Title: Re: Error: Project raised exception class 'External:SIGSEGV'.
Post by: EMTR on November 12, 2009, 07:38:19 pm
@Theo
?? Interface the dll?! I'm using the stdcall convention?

@Everyone
I have a strange problem though I've spent the afternoon narrowing down my problem. Consider the scenario...

I call the DLL using this code from Delphi (2009)... (This Delphi code is the exe)

Code: [Select]
function xyz(LibFileName : string) : IDataList;
var
  lCreateDataList: function: IDataList; stdcall;
begin
  FDLLHandle := LoadLibrary(PChar(LibFileName));
  { Check DLL loaded... }
  lCreateDataList := GetProcAddress(FDLLHandle, 'GetDataList');
  Result := lCreateDataList; 
end;

The DLL is built in Lazarus and I get into the DLL and all the way out of the DLL successfully - I think. So Lazarus has passed an IDataList back (appears to do this correctly), but on inspection the Pointer is different. It actually passes back an interface with a different pointer - This doesnt cause me a problem until I perform my next call from the Delphi exe..

Code: [Select]
function getItems(index : integer) : DataItem;
begin
  Result := IDataList.GetItems(0);
end;

Now I get back to the lazarus dll and it gets the correct offset because I load up the correct debug symbols and get into the "GetItems(index)" method... but on an Object that doesnt exist. I perform an operation on the object and get a SigSegV...

What have I done wrong?!

Everything works IF I build the exe via lazarus and the dll via lazarus.
Everything works IF I build the exe via Delphi 2009 and the dll via Delphi 2009.

As soon as I build the exe in Delphi 2009 and the DLL in lazarus it falls apart.

I need to exe in Delphi and DLL in Lazarus due to licensing and partners using lazarus etc so for them to extend our app, but we need to maintain the exe in Delphi 2009 just building both using the same compiler isn't an option....


Any thoughts? There's some problem with the pointer that I get when it crosses the Delphi / Lazarus boundary but I just can't figure out where I've gone wrong....
Title: Re: Error: Project raised exception class 'External:SIGSEGV'.
Post by: EMTR on November 12, 2009, 08:04:33 pm
Nearly 4,000 views on this thread.... that can't be right...
Title: Re: Error: Project raised exception class 'External:SIGSEGV'.
Post by: theo on November 13, 2009, 11:23:13 am
@Theo
?? Interface the dll?! I'm using the stdcall convention?

No, I meant that I for one would not assume that you can exchange data types from Delphi to Lazarus without problems.
I really don't know for sure (things are changing in FPC) but I would write the interface part as if I'd talk to C (maybe COM/OLE types would work too).
You'd better ask in the freepascal mailing list.
Title: Re: Error: Project raised exception class 'External:SIGSEGV'.
Post by: EMTR on November 13, 2009, 12:07:03 pm
Will do - Cheers. My next step is to build a simple DLL to just return an object via the interface see if I can figure it out from there.

Thanks for the help.
Title: Re: Error: Project raised exception class 'External:SIGSEGV'.
Post by: d9k on November 20, 2009, 03:07:05 am
OK, so I solved this problem. I am COMODO Internet Security user too.
Firstly I have downloaded Mark Russinvoch's program AutoRuns http://technet.microsoft.com/ru-ru/sysinternals/bb963902.aspx
, then I openned it, followed to AppInit tab and disabled guard32.dll.
Then I openned Comodo window, on Defense+ tab I clicked "My protected files", then "Groups..." button, found guard32.dll in "Comodo files/folders", have deleted it from list.

After it still on the "Defence+" tab I openned "My own safe files" item, and added lazarus.exe and /mingw/bin/gdb.exe from Lazarus folder.

On "advanced" tab at left I add them too to the "Computer Security Policy" as "Installer or updater" (max permissions).

Finally, I rebooted and gdb debugger began to work properly! :3
Title: Re: Error: Project raised exception class 'External:SIGSEGV'.
Post by: Troodon on November 20, 2009, 03:18:58 am
Teach your students either .net or java.

You can't be serious posting that to the Lazarus forum.
Title: Re: Error: Project raised exception class 'External:SIGSEGV'.
Post by: cdbc on November 20, 2009, 04:15:25 am
@EMTR - Hi
Quote
There's some problem with the pointer that I get when it crosses the Delphi / Lazarus boundary

1) Do you share memorymanager between host and lib?
2) If so, have you solved the differences between laz/fpc TMemoryManager and delphi TMemMgrEx.

Due to reference-counting I don't think you can export/use interfaces without sharing memory.
Maybe a solution would be to use an extra shared memmanager library, between to two?!?

HTH
Regards Benny
Title: Re: Error: Project raised exception class 'External:SIGSEGV'.
Post by: arcan on December 09, 2009, 09:56:59 pm
Hiya i ain't that great but maybee this is helpfull:

i got an old project in 9.24, today i downloaded 9.28 and while compiling that old project i got this error: Project raised exception class 'External:SIGSEGV'.
After reading here i uninstalled comodo, but that didn't help.

i browsed in the code and found out where it runs stuck on:
it fails with the first memo1 line:

procedure debugtxt(s: string);
begin
  Debug_form.Memo1.Clear ;
  Debug_form.Memo1.Append('1') ;
//  Debug_form.Memo1.Lines.Append(TimeToStr(Time) + ': ' + s);
  sob_tabellen_code.Frm_Tabellen.StatusBar1.Panels[1].Text:= s ;
end;                    

And it runs smooth with:
(alternated with and without 5 times and it was 5/5)

procedure debugtxt(s: string);
begin
//  Debug_form.Memo1.Clear ;
//  Debug_form.Memo1.Append('1') ;
//  Debug_form.Memo1.Lines.Append(TimeToStr(Time) + ': ' + s);
    sob_tabellen_code.Frm_Tabellen.StatusBar1.Panels[1].Text:= s ;
end;        

but then my memo field will remain empty, anyone got a clue what to do in order to fix it?
in the old lazarus i never had a problem with this btw.

I run under Windows Vista 64bit with FPC 2.2.4

Edit:
After making an other memo field it error's all the time, even after i deleted it.            
Title: Re: Error: Project raised exception class 'External:SIGSEGV'.
Post by: picstart on December 11, 2009, 04:05:15 pm
For me only lazarus 26.2 has been capable of reliable debugging. As a newcomer I always write a hello world program on any new IDE before proceeding. Now I have to admit I would have rejected lazarus entirely as being unreliable if I had started with 28.2 since it generates SigSEGV with win2k every time I run it no matter the code. Since 26.2 was stable and did not generate SIGSEV errors I was able to move many delphi projects over to lazarus. IMHO lazarus should be able to run a form with a button that when pressed populates a label with "hello world". Hello world should work on every platform that lazarus claims to support.
Title: Re: Error: Project raised exception class 'External:SIGSEGV'.
Post by: Marc on December 14, 2009, 12:26:01 pm
if I had started with 28.2 since it generates SigSEGV with win2k every time I run it no matter the code.

This is not related to the problem reported by arcan. One of the changes from 9.26 to 9.28 was a cleaner implementation of importing missing win32 functions not present in current FPC.
With this change there was made an error which affects all win9x, winNT and some win2k users.
Since none of the developers use those platforms it wasn't noticed until recently. Since a few weeks it is solved in trunk.
Title: Re: Error: Project raised exception class 'External:SIGSEGV'.
Post by: walter8088 on December 23, 2009, 06:48:59 am
Maybe I've already solved this problem,I just shut down the Trojan horse engine of my Anti-virus software. Then the window 'raised exception class External SIGSEGV'  disappeared. So I think that perhaps when the debugger runs , it also launched some plug-in or mid-ware which was wrongly treated as an Trojan horse virus so this windows appeared.

(original text)
也许我已经发现了解决这个问题的方法了,告诉大家:我将我机器上安装的防护软件中的木马防火墙功能关闭后,这个问题就再也没有出现过了,也许是调试器中调用的插件被木马防火墙误认为是木马程序了!不过我最后没有找到具体是哪个文件被误认为是木马了,否则我只要简单的在木马防火墙设置中将其加入信任程序列表后就不必整个关闭木马防火墙了,我试验了所有安装目录下的exe和dll文件好像都不能避免这个窗口的出现,所以以后编译的时候只能暂时先关闭木马防火墙了,然后用完了可别忘记打开木马防火墙啊,虽然有点麻烦,但还是管用的。

(Marc: added note of original text)
Title: Re: Error: Project raised exception class 'External:SIGSEGV'.
Post by: badgereden on January 11, 2010, 02:52:37 pm
Today,I have recieved the error message in another condition.

procedure TForm1.Button1Click(Sender: TObject);
begin
  self.Close;  //run well
end;

while I changed the codes self.Close to self.Free or self.Destroy,I recieved the error message such as the title.

I dont understand this error message,I hope somebody can help me.
Title: Re: Error: Project raised exception class 'External:SIGSEGV'.
Post by: theo on January 11, 2010, 03:03:09 pm
Why do you want to free the form this way?
You cannot do such things in the event handlers. It's like "suicide" ;-)

The message:
http://en.wikipedia.org/wiki/SIGSEGV


Title: Re: Error: Project raised exception class 'External:SIGSEGV'.
Post by: Marc on January 12, 2010, 01:12:28 am
If you want to do this, use release:
Code: Pascal  [Select][+][-]
  1. procedure TForm1.Button1Click(Sender: TObject);
  2. begin
  3.   self.Release;
  4. end;
Title: Re: Error: Project raised exception class 'External:SIGSEGV'.
Post by: piita on February 15, 2010, 08:36:45 pm
This SIGSEGV thing appeared every time for me too, even with a simple empty form. The problem was indeed Defense+ in Comodo Firewall as reported on other threads here. But the thing is that I have always had Defense+ turned off and only been using the firewall. Giving gdb.exe all access rights in Defense+ changed nothing, as did putting it in the My Own Safe Files category. I don't know if Comodos updater is to blame because when I removed and reinstalled the firewall, SIGSEGV was gone. So a clean install solved it in my case.

Considering how many threads there are about SIGSEGV and the amount of views on these, maybe it should be added to the FAQ or some common problems page.
Title: Re: Error: Project raised exception class 'External:SIGSEGV'.
Post by: theo on February 16, 2010, 01:04:23 am
Considering how many threads there are about SIGSEGV and the amount of views on these, maybe it should be added to the FAQ or some common problems page.

SIGSEGV is just a general POSIX error message which means that something went wrong with memory referencing.
There are zillions of different causes for a SIGSEGV, so a FAQ entry would not help a lot.
http://en.wikipedia.org/wiki/SIGSEGV
Title: Re: Error: Project raised exception class 'External:SIGSEGV'.
Post by: hovercraft on March 12, 2010, 03:48:49 am
 Hello everybody! I suppose these spurious External:SIGSEGV errors produced somehow by dgb itself when it makes try to catch any first-chance exception thrown in some external module (DLL) and fails to do it properly. These exceptions would be caught by the DLL itself been it ran without debugger. Under debugging session gdb takes over however (using it's "first-chance"). Exceptions itself caused in most cases by many antiviral programs and other soft which injects its dlls in every process.
 The solution in my opinion may be to disable gdb to catch first-chance exceptions of certain type. Unfortunately I don't know how to do it with Lazarus (at list in my version 0.9.23b).
 For example I have some function F1 in the DLL module f1.dll. When I call this function from a program built with VCExpress 2005 running under their debugger, I can see the following message in the debugger output window:
"First chance exception at ...: 0x000006BA: RPC server inaccessible" and execution continue normally because exception caught by DLL at "second chance".
 In contrast, when I call the same function from Lazarus IDE, execution stops at this point and famous "External:SIGSEGV" message shown.
The same behaviour will be with any Lazarus or gdb version, I believe.
Title: Re: Error: Project raised exception class 'External:SIGSEGV'.
Post by: Marc on March 12, 2010, 09:42:18 am
It's not implemented yet to control this from lazarus
Title: Re: Error: Project raised exception class 'External:SIGSEGV'.
Post by: Oldjoe on May 31, 2010, 06:03:07 pm
In my case, I discovered that the GbPlugin (installed in most of the homebank pages) was causing the 'External:SIGSEGV' problem.
I did this running the GDB through the command line.

c:\path_to_gdb\gdb your_app.exe

enter "r" followed by return
when it fails enter "bt" and read the trace.

I tried to uninstall the GbPlugin, but it is a nasty thing to uninstall.

Hope this helps,
 
Luigi Scarminio
Title: Re: Error: Project raised exception class 'External:SIGSEGV'.
Post by: Eugene Loza on August 05, 2010, 07:24:19 pm
OK, so I solved this problem. I am COMODO Internet Security user too.

Thanks a lot!!! That worked for me too!!!

Quote
Firstly I have downloaded Mark Russinvoch's program AutoRuns http://technet.microsoft.com/ru-ru/sysinternals/bb963902.aspx
, then I openned it, followed to AppInit tab and disabled guard32.dll

I've just found guard32.dll using regedit.exe and deleted its instance when it appears under AppInit parameter - much better than downloading and installing programs for single launch...
Title: Re: Error: Project raised exception class 'External:SIGSEGV'.
Post by: Marc on August 06, 2010, 12:34:06 am
I've just found guard32.dll using regedit.exe and deleted its instance when it appears under AppInit parameter - much better than downloading and installing programs for single launch...

You realize that you now have effectively disabled then on access virus scanning of your system ? You may want to look at a different virus scanner.
Title: Error: Project raised exception class 'External:SIGSEGV'.
Post by: JimR on August 08, 2010, 01:31:08 am
I am running Windows 7 64 bit, 9gb ram, I7 chipset, in a Dell Studio XPS 435T .  I have Comodo Firewall running but have set all of the Lazarus directory as safe.  I have Delphi 2010 on this machine also.  Even after setting all of Lazarus as safe I still get the 'External: SIGSEGV' error when I press 'F9'.  In case it helps, after pressing the 'OK' from the SIGSEGV error the Assembler window pops up with this line highlighted:
10012653  66813e4d5a     cmpw    $0x5a4d, (%esi)
Under the Run tab, I have 'Stop   Ctrl-F2' option highlighted, but nothing is running.  So I stop it.  I can use Windows Explorer and run the .exe file created by trying to compile and run the program and the program runs fine.  So it is building and compiling the program as it should, but it will not automatically run it, I have to do it manually.  It seems there are plenty of folks with this problem, plenty of 'try this or that' suggestions offered, but nothing that works.  I did shut down Comodo, no change in what happens.  That is about all I can think of that might be of any help in finding a solution. 

Somewhat of a separate issue.  Reading some solutions given the person presumes a knowledge level that may not always exist by the person having a problem.  Sometimes I fall into that category myself.  Try and keep solutions at a level that anyone can follow.  Just a thought. 

If this is truly a problem with a file name, change the file name so it will not conflict with other programs and be done with it.  Even if it means there are two files on the system with different names.  Better than fighting a never ending battle.  Better than saying don't use this firewall or anti-virus software or any other software.
Title: Re: Error: Project raised exception class 'External:SIGSEGV'.
Post by: Marc on August 08, 2010, 02:15:53 pm
This is a know problem with the comodo firewall. This firewall hooks a dll in every program you run. Even if you tell that a directory is OK, since it is checked after the hook.
The problem is that the debugger we use (gdb) and this hook doesn't work well together, resulting in a SIGSEGV. When running without debugger, either this exception is handled, otr it doesn't happen.

What you can do is contact Comodo, explain that you get a crash when you want to debug an application using gdb. Or you can switch to a different firewall (or you can turn off your firewall completely, but I don't think you want that)


BTW, this issue seems to be known at the comodo formum too: http://forums.comodo.com/bug-reports/guard32dll-and-gdb-problems-cfp-3025378-t25287.15.html

BTW2, this may solve it: http://forums.comodo.com/empty-t47299.0.html
Title: Re: Error: Project raised exception class 'External:SIGSEGV'.
Post by: JimR on August 08, 2010, 05:24:37 pm
Thanks for the reply, and I did try the mentioned entry that was given, same results.  But appreciate the try.  Maybe in the future this will get fixed, but at least it can use it, I just have to ignore the error message, stop the execution, and used Windows Explorer to kick off the .exe file to actually run my compiled program.  My hope is one day when Lazarus works as intended, I can stop paying for Delphi updates and totally switch to Lazarus.  It would be a lot cheaper to give a few hundred dollars to Lazarus as apposed to the big bucks I have to keep paying for Delphi.  In the mean time I'll keep playing with Lazarus from time to time and wait.

Might add all so, I disabled Comodo Virus Defense, Network Defense, and stopped all activities and I still get the same error message.
Title: Re: Error: Project raised exception class 'External:SIGSEGV'.
Post by: Marc on August 09, 2010, 08:20:40 pm
did you try to add gdb.exe to the exception list as the last url I gave suggested ?
Title: Re: Error: Project raised exception class 'External:SIGSEGV'.
Post by: JimR on August 09, 2010, 08:30:55 pm
Yes I went into Comodo and added gdb.exe, saved it, went back and tried again and still got the same SIGSEGV error. 
Title: Re: Error: Project raised exception class 'External:SIGSEGV'.
Post by: piita on August 10, 2010, 05:47:18 pm
I've got good news for Comodo users. I'm running a beta of CIS v5.0 and finally things compiles and debugs perfectly. 
The beta can be found here: http://fileforum.betanews.com/detail/Comodo-Internet-Security-32bit/1224699488/1 (http://fileforum.betanews.com/detail/Comodo-Internet-Security-32bit/1224699488/1)
But please check Comodo's web page first. The stable version might have been released.
 
Title: Re: Error: Project raised exception class 'External:SIGSEGV'.
Post by: JimR on August 10, 2010, 10:01:14 pm
piita got me all excited there.   So I downloaded the new Comodo Internet Security PREMIUM Ver 5.0.157302.1066, rebooted, fired up Lazarus, got the SIGSEGV error again.  It was a shot and had to go for it.  Still no joy.
Title: Re: Error: Project raised exception class 'External:SIGSEGV'.
Post by: piita on August 11, 2010, 04:16:39 pm
I'm sorry to hear that, JimR. I thought it was fixed since it worked now and I had nothing but problems before.
Title: Re: Error: Project raised exception class 'External:SIGSEGV'.
Post by: Eugene Loza on August 13, 2010, 04:26:15 pm
You realize that you now have effectively disabled then on access virus scanning of your system ? You may want to look at a different virus scanner.
Yes, of cource!
I've never ever used Comodo antivirus... And not going to...
Quote
did you try to add gdb.exe to the exception list as the last url I gave suggested ?
I'm afraid that doesn't work. At least it didn't work for me...
Title: Re: Error: Project raised exception class 'External:SIGSEGV'.
Post by: sieward on September 03, 2010, 04:06:07 pm
Today I tried to install lazarus (64bit) on my Windows7 notebook, and got the same problem, even with an empty application.

Reading all the coments I find out that BITDEFENDER (a dutch antivirus/firewall program) was my personal source of the problem. I find out that it was caused by the usage of the antivirus program (not the firewall!). However, I could solved it, by setting the Bitdefenders software into a "game-modus", and still be able to use the antivirus software. Sounds magic, but mayby this report  might help others users or even the developers.
Title: Re: Error: Project raised exception class 'External:SIGSEGV'.
Post by: chronozphere on October 18, 2010, 09:23:48 pm
I'm also having this problem. I reported it before I noticed this thread.  ::)

I've tried to fix it by disabling both my antivirus (AVG Free) and My firewall (PC Tools firewall) but no luck yet. :(

Any other things I could try?
Title: Re: Error: Project raised exception class 'External:SIGSEGV'.
Post by: ivan17 on October 19, 2010, 09:32:33 pm

I've tried to fix it by disabling both my antivirus (AVG Free) and My firewall (PC Tools firewall) but no luck yet. :(
you my friend seem to have a semantic problem. (or you didn't disable those completely)

as for the others, here is what i do on my winxp/comodo4 machine (same problem):
and like those of you who share the same problem i will be dropping comodo if the problem isn't fixed either by comodo update or by lazarus update...
Title: Re: Error: Project raised exception class 'External:SIGSEGV'.
Post by: Martin_fr on October 19, 2010, 09:55:38 pm
Today I tried to install lazarus (64bit) on my Windows7 notebook, and got the same problem, even with an empty application.

Reading all the coments I find out that BITDEFENDER (a dutch antivirus/firewall program) was my personal source of the problem. I find out that it was caused by the usage of the antivirus program (not the firewall!). However, I could solved it, by setting the Bitdefenders software into a "game-modus", and still be able to use the antivirus software. Sounds magic, but mayby this report  might help others users or even the developers.

Same here: bitdefender.
To be exact: "Active virus control" from the advanced settings.

You can put every individual app that you indent to debug, on the exception list there. IF you are lucky....
(putting just lazarus and/or gdb on the list, doesn't work)

Also, it does not alert you, even IF you explicitly check that field in bitdefender.

I wrote them (It is almost a year ago). They acknowledged the issue, and said, it would get fixed someday... (yeah...)

Guess who is not going to extend his license, once it runs out (unless they syill manage to fix it)?

---
Just to clarify:
I accept that a AV does catch a debugger. After all a debugger does strange things do another executable....
But:
- If an AV has an exclusion list, I would expect to put the debugger there, not the target app (the target app, after all is harmless)
- I definitely expect an AV to honour it's own settings (such as to ask me first, if I enable that)
Title: Re: Error: Project raised exception class 'External:SIGSEGV'.
Post by: picstart on October 21, 2010, 01:31:44 pm
Some would say the only totally effective anti virus answer is the power off button on your computer. If you are like most of us and need the power on then you are forced to trade convenience for security. I like convenience so security is second but some are in a different situation.
Title: Re: Error: Project raised exception class 'External:SIGSEGV'.
Post by: JD on October 22, 2010, 04:38:47 pm
I had the same problem & I'm a Comodo Internet Security user also. All I did was to add the GNU debugger as well as the temporary file created when unsaved project is run (C:\Temp\project1.exe) to CIS's Safe Files List & the problem disappeared.

I would not advise anyone to disable CIS's real-time malware scanner. It's just doing its job when it blocks files whose cryptographic footprint have changed from executing on the system.
Title: Re: Error: Project raised exception class 'External:SIGSEGV'.
Post by: chronozphere on February 07, 2011, 09:10:04 pm
I did another attempt to fight this error.

Tried to run a lazarus program + debugger in safe mode and that worked without any problems. That made me think AVG caused the problems, so I uninstalled it. However, the problem is still there (Only running PCTools firewall now). Disabling that one doesn't help either. :'(

Is there anything else that is disabled in safe mode and that is probably messing with lazarus now?



Title: Re: Error: Project raised exception class 'External:SIGSEGV'.
Post by: Rastrelly on February 23, 2011, 03:40:43 pm
This error may also appear simply due to mistakes in code... For example, it pops up if you try to do something with unexistant array element (a:array[1..100]of integer;   .......      a[0]:=1000;).
Title: Re: Error: Project raised exception class 'External:SIGSEGV'.
Post by: chronozphere on April 02, 2011, 01:29:05 am
YEHAA, Seems like I found the troublemaker.  >:D

It was HsMgr.exe which is part of the sound drivers of (some) Asus Xonar cards. Simply killing it manually with task-manager seems to work fine. Not sure if there are any side-effects when I remove the file from my registery, so that it doesn't run automatically. Sound still seems to work. :)

Hope this helps someone!
Title: Re: Error: Project raised exception class 'External:SIGSEGV'.
Post by: lazyprogrammer21 on June 19, 2011, 04:00:48 pm
Hello,
about the Comodo's guard32.dll.
Here is the working solution.

But first, if you are using Comodo Firewall, please do not disable or uninstall it. IMO there is no better free protection for the leaky Windows than Comodo's Firewall & Defence+ security mechanism. So, please DO NOT uninstall Comodo!!!

The solution to SIGSEGV problem concerning Comodo Firewall

Note: I use Comodo Firewall 5.4 and Lazarus 0.9.30.
I installed Lazarus to: C:\Dev\lazarus
I store all my Lazarus projects at: C:\Dev\projects\pascal


Do as follows:

I hope this will help.
For me it worked. And sorry, I do not know how the same thing could be achieved with other firewall software.
On the other hand, maybe I know ;)
Get rid of your current firewall and get yourself the one that is the best on the (free) market, that is the Comodo Firewall (I use it along with Avira Antivirus and I could not be happier), and add the piece of configuration as described above to make the GNU debugger work again.

Cheers,
Title: Re: Error: Project raised exception class 'External:SIGSEGV'.
Post by: M[a]nny on September 14, 2011, 02:41:01 am
lazyprogrammer21, thanks for the solution, it works like a charm! :)
Title: Re: Error: Project raised exception class 'External:SIGSEGV'.
Post by: avra on September 20, 2011, 01:53:16 pm
One similar debugger problem was fixed by replacing GDB with an old one. You can try that. The problem affected only WinXP, and was discussed here:
http://www.pilotlogic.com/sitejoom/index.php/forum/10-installationsetup/1189-gdb-problem-in-ct-200#1189
Title: Re: Error: Project raised exception class 'External:SIGSEGV'.
Post by: ehusmann on September 24, 2011, 06:47:01 pm
Being a new user of Lazarus, but a long time user of Delphi, I ran into the SIGSEGV problem yesterday. It happens when using the PDO units, but somehow I have the feeling it has little to do with that. Weird thing, to me, is that the problem occurs at the same point in the units. When I comment out the line the error happens on, I still get it on that line. When I add empty white lines, it still happens on the same line, etc etc.

I am using Lazarus 0.9.30 on Windows 7. Disabling the debugger didn't help, it just turned the error into an access violation. I am not using Comodo, so the well documented Comodo solution doesn't work for me. Anybody any other ideas about what I could do to get rid of this error?

THANKS!!
Erwin
Title: Re: Error: Project raised exception class 'External:SIGSEGV'.
Post by: avra on September 28, 2011, 07:24:15 pm
Before giving up Lazarus, you could try Lazarus CodeTyphon edition. But remember to first uninstall all previous Laz/FPC, and to install LazCT as admin user. Otherwise it will not work.
Title: Re: Error: Project raised exception class 'External:SIGSEGV'.
Post by: User137 on September 28, 2011, 07:51:00 pm
... Anybody any other ideas about what I could do to get rid of this error?
THANKS!!
Erwin
Is the application small enough so i could try compile and test it? SIGSEGV normally only happens if you have written error somewhere. Trying to access uninitialized objects, pointers etc.
Title: Re: Error: Project raised exception class 'External:SIGSEGV'.
Post by: ehusmann on October 06, 2011, 04:20:40 pm
Hi User137, yes the project isn't that big. In fact I was only just starting with it and it is basically only for testing something. However, it is with the PDO (Pascal Data Object) units to test the connection to a MySQL server. In other words, to test it (and to get the errors) you need to be able to connect to a MySQL server. If you have that installed I am more than happy to send the files to you so you can have a look.

Thanks!
Title: Re: Error: Project raised exception class 'External:SIGSEGV'.
Post by: tomday on October 30, 2011, 03:01:01 am
I am also having a 'External:SIGSEGV' error.

Have Windows XP SP3, AVG Free 2011 2Gig,

Just started a new project and getting the problem;  >:(

How do  I fix this, is it in Lazarus, or Debugger? :o
Title: Re: Error: Project raised exception class 'External:SIGSEGV'.
Post by: fhrancis on April 08, 2012, 02:51:49 am
Worked for me  :D
Thanks!!
Title: Re: Error: Project raised exception class 'External:SIGSEGV'.
Post by: Martin_fr on April 08, 2012, 03:14:50 am
I am also having a 'External:SIGSEGV' error.

Have Windows XP SP3, AVG Free 2011 2Gig,

Just started a new project and getting the problem;  >:(

I have avg and no issues.

- Which version of lazarus?
- 32 or 64 bit?
- Does the project work, if started outside lazarus? (run project1.exe from windows explorer)

If you don't yet use the latest (0.9.30.4) then try that. Or better, try the latest Lazarus 0.9.31 from snapshots.

If you upgrade make sure debugger config is NOT pointing to a previous version
http://wiki.lazarus.freepascal.org/Debugger_Setup


See also http://wiki.lazarus.freepascal.org/GDB_Debugger_Tips
Title: Re: Error: Project raised exception class 'External:SIGSEGV'.
Post by: User137 on April 08, 2012, 01:31:46 pm
This is a 6 months old thread... just saying. Projects can evolve alot in the time.
Title: Re: Error: Project raised exception class 'External:SIGSEGV'.
Post by: Martin_fr on April 08, 2012, 03:06:32 pm
Ups, I  didn't check all dates... The last msg before mine was new, causing the thread to appear in "recent unread"....
Title: Re: Error: Project raised exception class 'External:SIGSEGV'.
Post by: amadou on March 19, 2014, 04:51:39 pm
Hello..

I have just  installed Lazarus 1.2.0 on a Win Vista Home Prem 32bit.

Tried to debug a program and got the error message while quitting the program.

I went through the messages and solved the problem with changing the "gdb.exe" with the latest version from : http://sourceforge.net/projects/mingw/files/MinGW/Extension/gdb

Thanks.
Title: Re: Error: Project raised exception class 'External:SIGSEGV'.
Post by: andreynering on February 15, 2016, 12:51:46 am
I've got this exact error on Windows 10 (x64): on a new project (just a clean form) I get keep getting the SIGSEGV error and can do nothing at all. The only thing that works is running the .exe a part.

No antivirus or firewall installed. I tried to disable Windows Defender but had no luck.

I'm using the latest Lazarus (1.4.4,  FPC: 2.6.4). The same version works nice on Ubuntu Mate (latest). I've tried the 4.4.2 version as suggested in this other post: http://forum.lazarus.freepascal.org/index.php?topic=29448.0 but had no luck, too.  %)
Title: Re: Error: Project raised exception class 'External:SIGSEGV'.
Post by: andreynering on February 27, 2016, 05:45:42 pm
Quote
I've got this exact error on Windows 10 (x64): on a new project (just a clean form) I get keep getting the SIGSEGV error and can do nothing at all. The only thing that works is running the .exe a part.

No antivirus or firewall installed. I tried to disable Windows Defender but had no luck.

I'm using the latest Lazarus (1.4.4,  FPC: 2.6.4). The same version works nice on Ubuntu Mate (latest). I've tried the 4.4.2 version as suggested in this other post: http://forum.lazarus.freepascal.org/index.php?topic=29448.0 but had no luck, too.  %)

Fixed in Lazarus 1.6.0
Title: Re: Error: Project raised exception class 'External:SIGSEGV'.
Post by: OttoMan28 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
Title: Re: Error: Project raised exception class 'External:SIGSEGV'.
Post by: OttoMan28 on May 14, 2016, 10:40:35 pm
Well, a reinstall of Lazarus removed the problem.  :o
That is comforting ... not.
Title: Re: Error: Project raised exception class 'External:SIGSEGV'.
Post by: BMUN1 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...
Title: Re: Error: Project raised exception class 'External:SIGSEGV'.
Post by: ezlage on June 12, 2016, 05:10:09 am
I passed by this problem, and solved using the Alternative GDB. Did you tried this?

https://sourceforge.net/projects/lazarus/files/Lazarus%20Windows%2064%20bits/Alternative%20GDB/GDB%207.7/

https://sourceforge.net/projects/lazarus/files/Lazarus%20Windows%2032%20bits/Alternative%20GDB/GDB%207.7.1/
Title: Re: Error: Project raised exception class 'External:SIGSEGV'.
Post by: BMUN1 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!
Title: Re: Error: Project raised exception class 'External:SIGSEGV'.
Post by: pixelink 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.  
Title: Re: Error: Project raised exception class 'External:SIGSEGV'.
Post by: Akira1364 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
Title: Re: Error: Project raised exception class 'External:SIGSEGV'.
Post by: steve.huang 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()
Title: Re: Error: Project raised exception class 'External:SIGSEGV'.
Post by: Thaddy 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.
Title: Re: Error: Project raised exception class 'External:SIGSEGV'.
Post by: steve.huang 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
Title: Re: Error: Project raised exception class 'External:SIGSEGV'.
Post by: Cyrax 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.
Title: Re: Error: Project raised exception class 'External:SIGSEGV'.
Post by: steve.huang 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!
Title: Re: Error: Project raised exception class 'External:SIGSEGV'.
Post by: karmacomposer on December 08, 2020, 03:57:02 pm
I am getting this same problem.

This function (not written by me) is causing it:

Code: [Select]
function BinStr2Hex(S: AnsiString): AnsiString;
var
  i: integer;
begin
  Result := '';
  for i := 1 to Length(S)
    do Result := Result + LowerCase(HexStr(Byte(S[i]), 2));
end;

I tried PChar, I tried other things.  It always causes the error.

I am trying to encrypt a piece of data with DCPcrypt2 and this function turns the binary result into a hex string.

How can this be used and not throw that error?

Thanks.

Mike
Title: Re: Error: Project raised exception class 'External:SIGSEGV'.
Post by: rvk on December 08, 2020, 04:46:21 pm
Are you sure that the "S" string isn't zero-length?
That wouldn't matter for that function.
"for i := 1 to 0 do" won't execute anything.

I am getting this same problem.
This function (not written by me) is causing it:
Code: [Select]
function BinStr2Hex(S: AnsiString): AnsiString;
Could you show how this function is called.
The function itself should work fine with an ansistring as parameter.
Title: Re: Error: Project raised exception class 'External:SIGSEGV'.
Post by: Peter H on December 08, 2020, 05:15:47 pm
The error happens at this function, this doesnt mean, this function causes it.
Probably this means the problem is detected when the memory where the string is stored is accessed.

SigSEV means: "invalid memory access" and there should be a line number displayed, where the progamm fails.

If there is something wrong with the memory of the string argument, the error should occur when the content of the string is accessed.
So set a breakpoint there and examine the content of the string, or/and insert a Writeln or debugln to see the contents.

Probably the string is trashed by an array overflow or is uninitialized.
If the program is large or recursive, or the string is very large, stack overflow could be a reason.
(I believe there is a write protected guard page at the end of the stack segment, that causes SigSEV at stack overflow, but I do not know it)
Also I recommend to pass the string not by value but by reference as "constref" or "var" parameter to reduce unnecessary stack consumption and for performance.

Title: Re: Error: Project raised exception class 'External:SIGSEGV'.
Post by: karmacomposer on December 08, 2020, 08:13:22 pm
The error happens at this function, this doesnt mean, this function causes it.
Probably this means the problem is detected when the memory where the string is stored is accessed.

SigSEV means: "invalid memory access" and there should be a line number displayed, where the progamm fails.

If there is something wrong with the memory of the string argument, the error should occur when the content of the string is accessed.
So set a breakpoint there and examine the content of the string, or/and insert a Writeln or debugln to see the contents.

Probably the string is trashed by an array overflow or is uninitialized.
If the program is large or recursive, or the string is very large, stack overflow could be a reason.
(I believe there is a write protected guard page at the end of the stack segment, that causes SigSEV at stack overflow, but I do not know it)
Also I recommend to pass the string not by value but by reference as "constref" or "var" parameter to reduce unnecessary stack consumption and for performance.

Actually, the program runs fine.  It gives me this error, but if you try to run it again, it displays the hex strings just as it should.
There is no line number because there is no real error.

Code: [Select]
Uses section:

uses
  Classes, SysUtils, Forms, Controls, Graphics, Dialogs, StdCtrls, base64, DCPcrypt2, DCPsha256,
  DCPrijndael;

Type section:

type

  { TForm1 }

  TForm1 = class(TForm)
    btnPasswordGen: TButton;
    DCP_rijndael1: TDCP_rijndael;
    DCP_sha256_1: TDCP_sha256;
    lblEncryptedPassword: TLabel;
    lblHash: TLabel;
    memoShaHash: TMemo;
    memoEncryptedPassword: TMemo;
    memoPassword: TMemo;
    procedure btnPasswordGenClick(Sender: TObject); 

Var section:

var
  myHash : string;
  myPass : string;
  myNewPass : string;
  ex : string;
  result : string;
  myStringList: TStringList;
  myStringListEnc: TStringList;
  Cipher : TDCP_rijndael;

  // Variables for encryption
  Key    : AnsiString;
  IV     : AnsiString;
  Data   : AnsiString;

  CBC    : AnsiString;
  ECB    : AnsiString;
  Buffer : AnsiString;

  myKey : AnsiString;
  myIV : AnsiString;
  myData : AnsiString;
  myECB : AnsiString;
  myCBC : AnsiString;
  myBase64ECB : AnsiString;
  myBase64CBC : AnsiString;
  processECB : AnsiString;
  processCBC : AnsiString;

In the Begin/End section:

// Encrypt using Rijndael
   Data := 'Hello World_____';
   Key  := '1234567890______';
   IV   := '______1234567890';

   Cipher := TDCP_rijndael.Create(nil);
   Cipher.Init(Key[1], 256, @IV[1]);
   SetLength(Buffer, Length(Data));
   Cipher.EncryptECB(Data[1], Buffer[1]);
   Cipher.Free;
   ECB := Buffer;

   Cipher := TDCP_rijndael.Create(nil);
   Cipher.Init(Key[1], 256, @IV[1]);
   SetLength(Buffer, Length(Data));
   Cipher.EncryptCBC(Data[1], Buffer[1], Length(Data));
   Cipher.Free;
   CBC := Buffer;       

processECB := BinStr2Hex(ECB);
   processCBC := BinStr2Hex(CBC);

// Now write to the encryption memo control
   // Now write it to the password memo control

   processECB := BinStr2Hex(ECB);
   processCBC := BinStr2Hex(CBC);
   ECB := EncodeStringBase64(ECB);
   CBC := EncodeStringBase64(CBC);

   myKey := 'KEY        : '+ Key + ' - Length: ' + IntToStr(Length(Key));
   myIV := 'IV        : '+ IV + ' - Length: ' + IntToStr(Length(IV));
   myData := 'DATA        : '+ DATA + ' - Length: ' + IntToStr(Length(DATA));
   myECB := 'ECB        : '+ processECB + ' - Length: ' + IntToStr(Length(ECB));
   myCBC := 'CBC        : '+ processCBC + ' - Length: ' + IntToStr(Length(ECB));
   myBase64ECB := 'ECB_BASE64        : '+ ECB + ' - Length: ' + IntToStr(Length(ECB));
   myBase64CBC := 'CBC_BASE64        : '+ CBC + ' - Length: ' + IntToStr(Length(CBC));

   myStringListEnc:=TStringList.Create;               //Create my StringList
   myStringListEnc.Add(myKey);
   myStringListEnc.Add(myIV);
   myStringListEnc.Add(myData);
   myStringListEnc.Add(' ');
   myStringListEnc.Add(myECB);
   myStringListEnc.Add(myCBC);
   myStringListEnc.Add(myBase64ECB);
   myStringListEnc.Add(myBase64CBC);

   memoEncryptedPassword.Lines.Assign(myStringListEnc);               //assign text content
   myStringList.Free;                              //free my StringList

When I press the button to do its thing, I get the error followed by a assembler window with all 000000

Running it again gives me an access violation error, but the routine works and shows in the memo control.

I have no idea what's causing the error.

I am trying to use AES 256 encryption using DCPCrypt2

Thanks for any help.
Title: Re: Error: Project raised exception class 'External:SIGSEGV'.
Post by: Peter H on December 08, 2020, 09:12:42 pm
Just a hint: if you mark code examples as "pascal" in this forum, it becomes better readable and the code window can be enlarged.

I am not the right person to find an error in this code  :-[ it is too advanced for me.
However, I am convinced the error (corrupted data) was caused before calling this routine. (I tried the routine with 4Gb string, no crash, because it was running forever, I had to abort it)
In your projects debug options tick all checkmarks, stack check, range check and so on.
Then have a critical look to the call stack in debugger where you see all previously called routines and you can examine the local variables, even after an unhandled exception.
If you are on a 64 bit machine, you can easily give 1Gb Stack or more to your program, if this makes the error vanish, - or changes it substancially - it is probably a stack overrun.
On 32 bit a little bit less.
(An OS like windows or Linux should only map these memory pages that are actually used, and your program has its own adress space, so this does not mean more memory consumption)
Title: Re: Error: Project raised exception class 'External:SIGSEGV'.
Post by: rvk on December 08, 2020, 09:35:12 pm
Code: [Select]
SetLength(Buffer, Length(Data));
What makes you think that a buffer of size length(data) is enough?
The encrypted output is larger so there is some overwriting of memory space which results in your error.

I can't say exactly how large your buffer needs to be (I'm not behind a computer now) but it should be a multiple of blocksize.

Title: Re: Error: Project raised exception class 'External:SIGSEGV'.
Post by: karmacomposer on December 08, 2020, 09:44:29 pm
Code: [Select]
SetLength(Buffer, Length(Data));
What makes you think that a buffer of size length(data) is enough?
The encrypted output is larger so there is some overwriting of memory space which results in your error.

I can't say exactly how large your buffer needs to be (I'm not behind a computer now) but it should be a multiple of blocksize.

TBH, I am porting my technology from another language to Pascal using Lazarus.  I am very rusty - last time I programmed Pascal was on
Borland Delphi.

How would I enlarge the buffer size? What should I enlarge it to?

Some data to encrypt will be massive, so how would I know how large a buffer size I'd need?

I am using 64 bit Windows 10 and will want to port this to Mac, Linux, etc.

I just added 256 to each buffer size statement just to see if that would even work and I received
the same error, but this time with an address: 10001160F

Does anyone know what this means?  Assembler and machine code is not in my wheelhouse.

Thank you for your help.

Mike
Title: Re: Error: Project raised exception class 'External:SIGSEGV'.
Post by: karmacomposer on December 08, 2020, 10:04:39 pm
Ok, doing some experiments, if I change Length(Data) to a whole number, I was able to get to 12 with no errors.

I then wrote this:

Code: [Select]
varDataLen := (Length(Data) div 2);
I made that a int64 in the var staement

The following code works:

Code: [Select]
Cipher := TDCP_rijndael.Create(nil);
   Cipher.Init(Key[1], 256, @IV[1]);
   SetLength(Buffer, varDataLen);
   Cipher.EncryptECB(Data[1], Buffer[1]);
   Cipher.Free;
   ECB := Buffer;

   Cipher := TDCP_rijndael.Create(nil);
   Cipher.Init(Key[1], 256, @IV[1]);
   SetLength(Buffer, varDataLen);
   Cipher.EncryptCBC(Data[1], Buffer[1], varDataLen);
   Cipher.Free;
   CBC := Buffer;             

When I just do the Length of Data it = 24.  So 24 is too large and results in a error.

I am not sure why and what I need, but I need to encrypt this data reliably.

Funny enough, making the length 12 works and results in a ECB and CBC of 16, which is what it needed in this case, however,
other strings may be much larger.  I'll have to mess with it.

Any help is appreciated.

Mike
Title: Re: Error: Project raised exception class 'External:SIGSEGV'.
Post by: rvk on December 08, 2020, 11:26:40 pm
Code: [Select]
   Cipher.EncryptCBC(Data[1], Buffer[1], varDataLen);
You still need to pass Length(Data) as third parameter.
Third parameter is the length of data you want to encrypt. Not the size of the buffer.

But looking at your example, your Data is already a multiple of 16 (i.e. 16 exactly). So it should work fine. There would be no need to round the buffer to a 16 block (128 bits) size because it's already at that size. This would be needed if your string is not exactly multiple of 16 characters. See https://stackoverflow.com/a/41290878

But what happens if you use 128 in the Cipher init (like in the original example)?
You passed 256 (why?) which would indicate a key of 32 characters (while your key is just 16 characters).

2nd param to init needs to be keysize in bit (so * 8 ).
Code: Pascal  [Select][+][-]
  1. Cipher := TDCP_rijndael.Create(nil);
  2. Cipher.Init(Key1, Sizeof(Key1) * 8, nil);
  3. Cipher.EncryptECB(InData, Block);
https://wiki.freepascal.org/DCPcrypt
Title: Re: Error: Project raised exception class 'External:SIGSEGV'.
Post by: karmacomposer on December 09, 2020, 03:50:18 pm
Code: [Select]
   Cipher.EncryptCBC(Data[1], Buffer[1], varDataLen);
You still need to pass Length(Data) as third parameter.
Third parameter is the length of data you want to encrypt. Not the size of the buffer.

But looking at your example, your Data is already a multiple of 16 (i.e. 16 exactly). So it should work fine. There would be no need to round the buffer to a 16 block (128 bits) size because it's already at that size. This would be needed if your string is not exactly multiple of 16 characters. See https://stackoverflow.com/a/41290878

But what happens if you use 128 in the Cipher init (like in the original example)?
You passed 256 (why?) which would indicate a key of 32 characters (while your key is just 16 characters).

2nd param to init needs to be keysize in bit (so * 8 ).
Code: Pascal  [Select][+][-]
  1. Cipher := TDCP_rijndael.Create(nil);
  2. Cipher.Init(Key1, Sizeof(Key1) * 8, nil);
  3. Cipher.EncryptECB(InData, Block);
https://wiki.freepascal.org/DCPcrypt

I need to use AES 256, so how would I achieve that with a 32 character key? I already have the ability to create/trim 32 character keys.

Mike
Title: Re: Error: Project raised exception class 'External:SIGSEGV'.
Post by: rvk on December 09, 2020, 04:16:40 pm
I need to use AES 256, so how would I achieve that with a 32 character key? I already have the ability to create/trim 32 character keys.
Make your Key 32 bytes long.

Also... the Data string should be a multiple of 16.
In your case it happens to be that size but if not you can add the following to make sure.
Code: Pascal  [Select][+][-]
  1. if (Length(Data) mod 16 > 0) then
  2.    for I := 1 to (16 - (Length(Data) mod 16)) do
  3.      Data := Data + AnsiChar(0);

If you still get an error you'll need to provide compilable code and input for reproducing this error.
Title: Re: Error: Project raised exception class 'External:SIGSEGV'.
Post by: karmacomposer on December 09, 2020, 04:57:58 pm
I need to use AES 256, so how would I achieve that with a 32 character key? I already have the ability to create/trim 32 character keys.
Make your Key 32 bytes long.

Also... the Data string should be a multiple of 16.
In your case it happens to be that size but if not you can add the following to make sure.
Code: Pascal  [Select][+][-]
  1. if (Length(Data) mod 16 > 0) then
  2.    for I := 1 to (16 - (Length(Data) mod 16)) do
  3.      Data := Data + AnsiChar(0);

If you still get an error you'll need to provide compilable code and input for reproducing this error.

Thank you for this.  So, since the data could be any size, from as small as a first name to several paragraphs in size, the above code will simply make sure
it is divisible by 16, correct? As far as making the key 32 bytes long, won't a 32 character key be 32 bytes long?

Thank you very much.  Your help is invaluable.

Mike
Title: Re: Error: Project raised exception class 'External:SIGSEGV'.
Post by: rvk on December 09, 2020, 05:27:27 pm
Thank you for this.  So, since the data could be any size, from as small as a first name to several paragraphs in size, the above code will simply make sure
it is divisible by 16, correct?
Yes, the Data should be divisible by Cipher.BlockSize div 8 (which is 128 div 8 = 16).
TDCP_rijndael is inherited from TDCP_blockcipher128 and for that one the standard blocksize is 16, 128 bits.
So you could use Cipher.BlockSize div 8 in the code but because for rijndael it's always 128 bits (16 bytes) you can hardcode the padding to a multiple of 16 characters.

Also... if you look in TDCP_blockcipher128.EncryptCBC() you can see the encoding is done in blocks of 16.
(Set your cursor on .EncryptCBC( and press Alt+Arrow Up and then Shift+Ctrl+Arrow Down. You get right into the source there)

You can see it does blocks of 16 bytes from the for i:= 1 to (Size div 16) and Move(p1^,p2^,16);

As far as making the key 32 bytes long, won't a 32 character key be 32 bytes long?
Yes, a 32 character long ansistring is 32 bytes long. But make sure it's an ansistring and not a utf8 string (which can be longer due to character encoding with special characters).

You could also padd the key if it's shorter than 32 characters. But that might weaken your AES encryption.

Code: Pascal  [Select][+][-]
  1. if (Length(Key) < 32) then
  2.   while Length(Key) < 32 do Key := Key + AnsiChar(0);
  3. Key := Copy(Key, 1, 32); // for the instance Length(Key) > 32
Title: Re: Error: Project raised exception class 'External:SIGSEGV'.
Post by: karmacomposer on December 09, 2020, 05:55:50 pm
Thank you for this.  So, since the data could be any size, from as small as a first name to several paragraphs in size, the above code will simply make sure
it is divisible by 16, correct?
Yes, the Data should be divisible by Cipher.BlockSize div 8 (which is 128 div 8 = 16).
TDCP_rijndael is inherited from TDCP_blockcipher128 and for that one the standard blocksize is 16, 128 bits.
So you could use Cipher.BlockSize div 8 in the code but because for rijndael it's always 128 bits (16 bytes) you can hardcode the padding to a multiple of 16 characters.

Also... if you look in TDCP_blockcipher128.EncryptCBC() you can see the encoding is done in blocks of 16.
(Set your cursor on .EncryptCBC( and press Alt+Arrow Up and then Shift+Ctrl+Arrow Down. You get right into the source there)

You can see it does blocks of 16 bytes from the for i:= 1 to (Size div 16) and Move(p1^,p2^,16);

As far as making the key 32 bytes long, won't a 32 character key be 32 bytes long?
Yes, a 32 character long ansistring is 32 bytes long. But make sure it's an ansistring and not a utf8 string (which can be longer due to character encoding with special characters).

You could also padd the key if it's shorter than 32 characters. But that might weaken your AES encryption.

Code: Pascal  [Select][+][-]
  1. if (Length(Key) < 32) then
  2.   while Length(Key) < 32 do Key := Key + AnsiChar(0);
  3. Key := Copy(Key, 1, 32); // for the instance Length(Key) > 32

I get all that, though great info to be sure.  I require AES 256, so is Rijndael AES 128? How would I use it for AES 256? I require very strong encryption.

I have every intention of converting the resulting encrypted AnsiString to UTF8 after and then the reverse when decrypting.
I need to be able to transmit through SSL and I have learned that converting to UTF8 does the trick.

Mike
Title: Re: Error: Project raised exception class 'External:SIGSEGV'.
Post by: rvk on December 09, 2020, 06:06:39 pm
I require AES 256, so is Rijndael AES 128? How would I use it for AES 256? I require very strong encryption.
By using a 32 byte key (=256 bits), I thought.
Keysize is different than blocksize.

Quote
For AES, NIST selected three members of the Rijndael family, each with a block size of 128 bits, but three different key lengths: 128, 192 and 256 bits.
https://en.m.wikipedia.org/wiki/Advanced_Encryption_Standard
Title: Re: Error: Project raised exception class 'External:SIGSEGV'.
Post by: PascalDragon on December 10, 2020, 09:42:51 am
As far as making the key 32 bytes long, won't a 32 character key be 32 bytes long?
Yes, a 32 character long ansistring is 32 bytes long. But make sure it's an ansistring and not a utf8 string (which can be longer due to character encoding with special characters).

Though Length will return the length in Byte, not characters or code points, so that wouldn't matter here.
Title: Re: Error: Project raised exception class 'External:SIGSEGV'.
Post by: Fred vS on January 12, 2021, 08:14:29 pm
Hello.

In your code:

Code: Pascal  [Select][+][-]
  1. for I := 0 to High(txtArray) do
  2.     begin
  3.       if txtArray[I] <> '' then
  4.         newArray[I] := txtArray[I]
  5.       else
  6.         newArray[I] := 'empty';
  7.     end;

I dont see before a SetLength(newArray, something);
Title: Re: Error: Project raised exception class 'External:SIGSEGV'.
Post by: karmacomposer on January 12, 2021, 08:24:38 pm
Hello.

In your code:

Code: Pascal  [Select][+][-]
  1. for I := 0 to High(txtArray) do
  2.     begin
  3.       if txtArray[I] <> '' then
  4.         newArray[I] := txtArray[I]
  5.       else
  6.         newArray[I] := 'empty';
  7.     end;

I dont see before a SetLength(newArray, something);

Thank you.

I rewrote the code and found the problems.

Mike
Title: Re: Error: Project raised exception class 'External:SIGSEGV'.
Post by: Pluto on March 26, 2021, 08:38:53 pm
For people coming to this in 2021, it may not be a problem with the debugger, as discussed in this thread.  It may be a problem with your program.  If you want to figure it out, go into Project -> Project Options, then Select Debugger, and turn on all the checks and asserts (I/O, Range, Overflow, Stack, Verify method calls, Include assertion code), and run it again.  See the attached for a screenshot
TinyPortal © 2005-2018