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?
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
Project raised exception class: 'External: SIGSEGV'
Execution Paused
Address: $10009631
Procedure: ??
File:
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
Project raised exception class: 'External: SIGSEGV'But it appears after my program is started. Program works perfectly until it comes to command:
Image1.Picture.Graphic.Width:=Image1.Width;THEN program shows this error. Can somebody help?
Image1.Picture.Graphic.Height:=Image1.Height;
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...
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;
function getItems(index : integer) : DataItem;
begin
Result := IDataList.GetItems(0);
end;
@Theo
?? Interface the dll?! I'm using the stdcall convention?
Teach your students either .net or java.
There's some problem with the pointer that I get when it crosses the Delphi / Lazarus boundary
if I had started with 28.2 since it generates SigSEGV with win2k every time I run it no matter the code.
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.
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
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.Yes, of cource!
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...
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)
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.
... Anybody any other ideas about what I could do to get rid of this error?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.
THANKS!!
Erwin
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'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. %)
I got the same error 'External SIGSEGV' today....I did it follow your suggestion,but got a wrong return result when I try to convert the PChar to string with StrPas()
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:
Function getMsg():String; stdcall; to Function getMsg():PChar; stdcall;
THE APP:
type TMyDLL = function(): String; stdcall; to type TMyDLL = function(): PChar; stdcall;
...
library mydll; {$mode objfpc}{$H+} uses Classes, SysUtils, Windows { you can add units after this }; function myMessage(): string; stdcall; begin MessageBox(0,PChar('Hello world'),PChar(''),MB_OK); end; Function WinUserName(): PChar; stdcall; var FStr: PChar; FSize: Cardinal; begin FSize := 255; GetMem(FStr, FSize); Windows.GetUserName(FStr, FSize); Result :=FStr; FreeMem(FStr) end; ...
Write sample code here please!...
library mydll; {$mode objfpc}{$H+} uses Classes, SysUtils, Windows { you can add units after this }; function myMessage(): string; stdcall; begin MessageBox(0,PChar('Hello world'),PChar(''),MB_OK); end; Function WinUserName(): PChar; stdcall; var FStr: PChar; FSize: Cardinal; begin FSize := 255; GetMem(FStr, FSize); Windows.GetUserName(FStr, FSize); Result :=FStr; FreeMem(FStr) end; ...
Remove FreeMem(FStr) and do your cleaning up (freeing memory etc.) in your main code.
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;
Are you sure that the "S" string isn't zero-length?That wouldn't matter for that function.
I am getting this same problem.Could you show how this function is called.
This function (not written by me) is causing it:Code: [Select]function BinStr2Hex(S: AnsiString): AnsiString;
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.
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
What makes you think that a buffer of size length(data) is enough?Code: [Select]SetLength(Buffer, Length(Data));
What makes you think that a buffer of size length(data) is enough?Code: [Select]SetLength(Buffer, Length(Data));
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.
varDataLen := (Length(Data) div 2);
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;
You still need to pass Length(Data) as third parameter.Code: [Select]Cipher.EncryptCBC(Data[1], Buffer[1], varDataLen);
You still need to pass Length(Data) as third parameter.Code: [Select]Cipher.EncryptCBC(Data[1], Buffer[1], varDataLen);
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 ).https://wiki.freepascal.org/DCPcrypt
Cipher := TDCP_rijndael.Create(nil); Cipher.Init(Key1, Sizeof(Key1) * 8, nil); Cipher.EncryptECB(InData, Block);
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.
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.
if (Length(Data) mod 16 > 0) then for I := 1 to (16 - (Length(Data) mod 16)) do 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 sureYes, the Data should be divisible by Cipher.BlockSize div 8 (which is 128 div 8 = 16).
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?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).
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 sureYes, the Data should be divisible by Cipher.BlockSize div 8 (which is 128 div 8 = 16).
it is divisible by 16, correct?
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.
if (Length(Key) < 32) then while Length(Key) < 32 do Key := Key + AnsiChar(0); Key := Copy(Key, 1, 32); // for the instance Length(Key) > 32
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.
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
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).
Hello.
In your code:
for I := 0 to High(txtArray) do begin if txtArray[I] <> '' then newArray[I] := txtArray[I] else newArray[I] := 'empty'; end;
I dont see before a SetLength(newArray, something);