Forum > General
Project raises exception class "External SIGSEGV"
passt:
Lazarus 1.8.4 FPC 3.0.4 (x86_64-win32/win64)
Windows 7 Prof x64
I have a project which compiles successfully, but when I run it from IDE an error is shown:
Error: Project raised exception class "External SIGSEGV"
When I run it by its EXE file an access violation is shown.
The error is shown for a line in unit2 where a global variable of type TStringlist is used. The global variable is declared and created in another unit1. Both units refer to each other by "uses unit1/2".
Can anybody help?
Peter
munair:
You shouldn't cross reference units. Use unit 2 in unit 1 or unit 1 in unit 2, but not both. Also, it would be helpful if you provide the source. Otherwise there's no way anyone can help.
passt:
Well I need the cross reference of the units, at least for my bad and unexperienced programming style :(
Here is my (shortened) code
--- Code: Pascal [+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i < x.length; i++) { x[i].style.maxHeight='none'; x[i].style.height = Math.min(x[i].clientHeight+15,306)+'px'; x[i].style.resize = "vertical";}};} ---unit Unit1;{$mode objfpc}{$H+}interface ...var slFLartikel: TStringlist;implementationuses Unit2;{$R *.lfm}{ TForm1 } procedure TForm1.myproc1();begin slFLartikel := TStringlist.Create; myproc2; Form2.show; slFLartikel.free;end; procedure TForm1.myproc2();begin while ... do slFLartikel.Add(someString);end; ### unit Unit2;{$mode objfpc}{$H+}interface ...implementationuses Unit1;{$R *.lfm}{ TForm2 } procedure TForm2.myproc3();begin For i := 0 to slFLartikel.Count-1 do showmessage(slFLartikel[i]);end;
munair:
You never have to cross reference units. If you need definitions in more than one unit, then create a general one for those definitions. In your case, unit3 could contain the definition
--- Code: Pascal [+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i < x.length; i++) { x[i].style.maxHeight='none'; x[i].style.height = Math.min(x[i].clientHeight+15,306)+'px'; x[i].style.resize = "vertical";}};} ---var slFLartikel: TStringlist;and both unit1 and unit2 can use unit3.
passt:
I changed the code as you proposed exactly. Added unit3 and removed the references for unit1/2 to each other.
Unfortunately the SIGSEGV error still happens. This error is shown even when I start the program.
--- Code: Pascal [+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i < x.length; i++) { x[i].style.maxHeight='none'; x[i].style.height = Math.min(x[i].clientHeight+15,306)+'px'; x[i].style.resize = "vertical";}};} ---unit Unit1;{$mode objfpc}{$H+}interface ...var slFLartikel: TStringlist;implementationuses Unit3;{$R *.lfm}{ TForm1 } procedure TForm1.myproc1();begin slFLartikel := TStringlist.Create; myproc2; //Form2.show; slFLartikel.free;end; procedure TForm1.myproc2begin while ... do slFLartikel.Add(someString);end; ###unit Unit2;{$mode objfpc}{$H+}interface ...implementationuses Unit3;{$R *.lfm}{ TForm2 } procedure TForm2.myproc3();begin For i := 0 to slFLartikel.Count-1 do showmessage(slFLartikel[i]);end; ###unit Unit3;{$mode objfpc}{$H+}interfaceuses Classes, SysUtils;var slFLartikel: TStringlist;implementation end.
Btw is the reference to each other bad coding only or is forbidden definitely?
Navigation
[0] Message Index
[#] Next page