Without any warning, the app built in Lazarus no longer starts. lazarus / 31-LCL ---------------------------------------------------------------------- TakamiChie · 2021-12-17 03:57 The app I'm developing in Lazarus is no longer working at all than yesterday(12/16). When debugging on Lazarus, an error seems to have occurred in the CreateForm method of the lpr file. Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i begin  RequireDerivedFormResource:=True;  Application.Title:='ClipboardMonitor';  Application.Scaled:=True;  Application.Initialize;  Application.CreateForm(TMainForm, MainForm); // <- Error occurs  Application.Run;end.  At the point where the error occurred in the above code, "Exception class 'RunError(204)'" was generated. It seems that the error occurs. When following the process in the step-in, it was found that an error occurred in "TWinControl.WSRegisterClass" of "wincontrol.inc". You know that an error has occurred before the form's method is called. Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i class procedure TWinControl.WSRegisterClass;begin  inherited WSRegisterClass; // <- Error occurs  RegisterWinControl;  RegisterPropertyToSkip(TWinControl, 'ParentDoubleBuffered', 'VCL compatibility property', '');  RegisterPropertyToSkip(TWinControl, 'ImeMode', 'VCL compatibility property', '');  RegisterPropertyToSkip(TWinControl, 'ImeName', 'VCL compatibility property', '');end;  If you deploy and run the application in another environment that you own, it is working as expected. * Windows PC(Windows 10 Home 21H1) * Windows Sandbox Environment From this, it is thought that the problem occurs not only by the problem in the program but also by some changes on the PC, but there is no change made to the PC the day before yesterday (12/15), and it is a state that does not know what to do at all. Just in case, after checking the SMART of the disk, "DISM.exe /Online /Cleanup-image /Restorehealth" and "sfc /scannow" were executed to confirm that all problems were repaired. If this happens, where is it correct to investigate? ---------------------------------------------------------------------- TakamiChie · 2021-12-17 04:13 I forgot to write, but the environment I'm using is Windows 10 Professional 21H2 64bit, Core i5-7500 CPU @ 3.40GHz, 32.0 GB RAM. ---------------------------------------------------------------------- ccrause · 2021-12-17 05:17 Is the problem specific to this project, or does it occur with a new project with only an empty form too? ---------------------------------------------------------------------- TakamiChie · 2021-12-17 05:44 Thanks for the reply. Quote from: ccrause on December 17, 2021, 06:17:57 amIs the problem specific to this project, or does it occur with a new project with only an empty form too? Yes. This is a project-specific issue. There were no problems with empty projects and forms with the same LCL components as this project. The LCL components used in this form are as follows. TMemoTSplitterTStatusBarTIpHtmlPanelTPopupMenuTActionList ---------------------------------------------------------------------- dbannon · 2021-12-17 06:12 Just to be clear here TakamiChie, are you saying that your code builds fine but crashes when you run it ? But if you take the newly made binary to another system, it runs OK ? When it crashes on you working machine, are you running it from within the IDE ? Or standalone ? If it only crashes in the IDE, have you tried running it, still in the IDE but without debugging ? Davo ---------------------------------------------------------------------- Zvoni · 2021-12-17 07:18 And which FPC/Laz-Version do you use? ---------------------------------------------------------------------- TakamiChie · 2021-12-17 11:23 Thanks for the reply. Quote from: dbannon on December 17, 2021, 07:12:03 amJust to be clear here TakamiChie, are you saying that your code builds fine but crashes when you run it ? Yes. The build succeeds, but crashes at run time. Quote from: dbannon on December 17, 2021, 07:12:03 amBut if you take the newly made binary to another system, it runs OK ? Yes. If you move the created binaries to another environment, it will work fine. Quote from: dbannon on December 17, 2021, 07:12:03 amWhen it crashes on you working machine, are you running it from within the IDE ? Or standalone ? I did all of the following: Debugging execution on the IDE.Run the binary with debug information stand-alone.Run binaries standalone with no debug information left. In all, the program was killed before the application's screen was fully displayed. Quote from: Zvoni on December 17, 2021, 08:18:52 amAnd which FPC/Laz- Version do you use? Lazarus Version: 2.0.12 FPC Version: 3.2.0 ---------------------------------------------------------------------- Zvoni · 2021-12-17 11:31 Runerror 204 Quote 204 Invalid pointer operation     You will get this in several cases:         if you call Dispose or Freemem with an invalid pointer         in case New or GetMem is called, and there is no more memory available. The behavior in this case depends on the setting of ReturnNilIfGrowHeapFails. If it is True, then Nil is returned. if False, then runerror 204 is raised. Sounds like you're out of memory or your physical RAM is damaged ---------------------------------------------------------------------- Martin_fr · 2021-12-17 11:56 Might need more details on the error.... But let's go there later. Let's look at what we have. You may want to start with "4a", and then check the other points. Quote from: TakamiChie on December 17, 2021, 04:57:47 amWhen following the process in the step-in, it was found that an error occurred in "TWinControl.WSRegisterClass" of "wincontrol.inc". 1) Menu: Project > View Project Source That should be the file from which you already quoted. With all the "Application.*" calls. It should start with Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i program YourProgramsName; {$mode objfpc}{$H+} uses  {$IFDEF UNIX}  cthreads,  {$ENDIF}  TestDbgControlForm,  Interfaces, .........  Make sure "Interfaces" is in the "uses" clause. 2) - Open "Project Options" - Page "Compiler Options" > "Config and Target" On the bottom of the page it should say Code: Text  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i Current LCL WidgetSet: "win32"Make sure it is "win32", since you are on Windows. (Yes, this is correct for 64bit too) 3) Do you have any unit with an "initialization" unit? If you do, does it call any LCL functions like "ShowMessage", or use a "TOpenDialog" .... In order to find out, set a breakpoint on Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i   RequireDerivedFormResource:=True;Or, on whatever is the very first line, in the "begin" block of the "project source". If the error happens, before the breakpoint is reached, then you most likely have something in an "initialization" section. 4) Do a clean build. a) You can choose menu: Run > Build b) Clean by hand Open the folder with the project. ===> At this point: Backup the entire folder. There is either a "lib" (or "units") dir. It contains an x86_64-win64 or i386-win32 subdir. -> From that subdir, remove all files. Open all Forms in your project, and modify them (move them a few pixel on your monitor, so the coordinates are changed), the save them. (The "forms" bit, is 99.9% NOT related to your issue, but just to be save.) Now  "build" again, and test. 5) More info, if nothing so far has helped or revealed at least more details. Open the menu: View > Debug Windows > Stack Copy the content when you hit the error. The top, up to 3 entries may not have unit/lines. The may have names like "FPC_RUNERROR", "FPC_EXCEPTION", reference to system, sysutils. After that, if the next lines in the stack, do not have unit names and lines, go to menu: Tools > "Configure build IDE", and add -gw  to the Custom options. No need to build, just save. Build and run again, hopefully the stack now has lines. ---------------------------------------------------------------------- dbannon · 2021-12-18 00:38 yes, the fact that it runs OK on other machines says its probably not a code issue. I'd be running a memcheck first off ..... (Most linux install ISOs offer to do a memcheck before booting, be a good start ..) But Windows does have a limited number of a few particular resources too, not my field. Davo ---------------------------------------------------------------------- marcov · 2021-12-18 11:07 Security software is also always a possibility. Specially if you have something that initializes network on those forms. ---------------------------------------------------------------------- wp · 2021-12-18 15:33 The usual suspect when something suddenly does not work any more, is the virus scanner which could have received an update with a "super- intelligent" feature a minute ago. Please read my notes on this in the other thread: https://forum.lazarus.freepascal.org/index.php/topic,575 75.msg428315.html#msg428315 ---------------------------------------------------------------------- marcov · 2021-12-18 15:37 Quote from: wp on December 18, 2021, 04:33:22 pmThe usual suspect when something suddenly does not work any more, is the virus scanner which could have received an update with a "super-intelligent" feature a minute ago. Please read my notes on this in the other thread: https:// forum.lazarus.freepascal.org/index.php/topic,57575.msg428315.html#msg4 28315 A firewall blocking e.g. the creation of a socket can also be the cause. Which is why I generalized to "security software" ---------------------------------------------------------------------- TakamiChie · 2021-12-20 04:32 Thanks for the reply. Quote from: Zvoni on December 17, 2021, 12:31:34 pmSounds like you're out of memory or your physical RAM is damaged Quote from: dbannon on December 18, 2021, 01:38:34 amyes, the fact that it runs OK on other machines says its probably not a code issue. I'd be running a memcheck first off ..... (Most linux install ISOs offer to do a memcheck before booting, be a good start ..) But Windows does have a limited number of a few particular resources too, not my field. For RAM problems, I tried Running Windows Memory Diagnostics (MdSched.exe), but no particular problems were detected. Quote from: marcov on December 18, 2021, 12:07:50 pmSecurity software is also always a possibility. Specially if you have something that initializes network on those forms. I use windows security features. Therefore, as an item to exclude from the scan of [Windows Security >Virus & threat protection > Virus & threat protection Settings > Excluded], I set two folders of the project folder and the folder with lazarus executable as excluded folders and executed again. However, there was no change in the content of the error. In addition, This application does not use the function to access the Internet. Quote from: Martin_fr on December 17, 2021, 12:56:47 pm1) Menu: Project > View Project Source That should be the file from which you already quoted. With all the "Application.*" calls. It was confirmed that it is a method call of the Application object except for the setting of the RequestDerivedFormResource variable described later. Interfaces units are also included in the uses. Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i uses  {$IFDEF UNIX}{$IFDEF UseCThreads}  cthreads,  {$ENDIF}{$ENDIF}  Interfaces, // this includes the LCL widgetset  Forms, Main, ClipboardListener, Utils, Settings, Localization, Preferences,  ScriptManager, ScriptProcess, AboutDialog;  Quote from: Martin_fr on December 17, 2021, 12:56:47 pm2) - Open "Project Options" - Page "Compiler Options" > "Config and Target" Yes. It is set to win32. Quote from: Martin_fr on December 17, 2021, 12:56:47 pm3) Do you have any unit with an "initialization" unit? If you do, does it call any LCL functions like "ShowMessage", or use a "TOpenDialog" .... There are unit files listed in the "initialization" section, but only two are done: * The process of loading a resource file in lrs format * Windows API loading process There is no action involving the display of dialogs. Quote from: Martin_fr on December 17, 2021, 12:56:47 pm 4) Do a clean build. a) You can choose menu: Run > Build b) Clean by hand I tried both operations, but no change occurred (no error message has changed). Quote from: Martin_fr on December 17, 2021, 12:56:47 pm5) More info, if nothing so far has helped or revealed at least more details. Open the menu: View > Debug Windows > Stack Copy the content when you hit the error. When the IDE configuration has not been changed, it looks like this: Code: Text  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i #0 SYSTEM_$$_HANDLEERRORADDRFRAME$LONGINT$POINTER$POINTER at :0#1 SYSTEM_$$_HANDLEERRORADDRFRAME$LONGINT$POINTER$POINTER at :0#2 ?? at :0#3 SYSTEM_$$_SETMULTIBYTERTLFILESYSTEMCODEPAGE$WORD at :0#4 ?? at :0#5 fpc_widestr_setlength at :0#6 ?? at :0#7 ?? at :0#8 ?? at :0#9 fpc_unicodestr_to_widestr at :0#10 ?? at :0#11 ?? at :0  It was found that the execution of the program stopped in the following places only if no breakpoint was set after the configuration change of the build construction. Code: Text  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i #0 VerifierDisableFaultInjectionExclusionRange at :0#1 ?? at :0#2 ?? at :0#3 ?? at :0#4 ?? at :0#5 ?? at :0  After this, when the execute button is pressed, the process proceeds, but the following message is displayed, and the application is terminated. Code: Text  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i Project ClipboardMonitor raised an exception class 'External: ? exception. applicable address 7FFDC3DA4F69 ---------------------------------------------------------------------- Seenkao · 2021-12-20 04:46 продублируйте проект. В дубликате: удалите файл *.lpi, удалите файл ресурсов. Откройте проект из Lazarus через файл *.lpr. Возможно вам повезёт и ваш проект запустится. Не забудьте прописать необходимые пути заново. То что я написал - это не лучшее решение, но бывает рабочим способом избежания проблем. Google translate: duplicate the project. In the copied project: delete the * .lpi file, delete the resource file. Open your project from Lazarus via * .lpr file. Perhaps you are lucky and your project will start. Do not forget to re-register the required paths. What I wrote is not the best solution, but it can be a working way to avoid problems. ---------------------------------------------------------------------- dseligo · 2021-12-20 13:48 I once had similar problem (I don't remember exact error message) because there were no printers installed. Do you use dll in your program, maybe there is access issue? ---------------------------------------------------------------------- TakamiChie · 2021-12-21 05:44 Thanks for the reply. Quote from: Seenkao on December 20, 2021, 05:46:31 amduplicate the project. In the copied project: delete the * .lpi file, delete the resource file. Open your project from Lazarus via * .lpr file. Perhaps you are lucky and your project will start. Do not forget to re-register the required paths. What I wrote is not the best solution, but it can be a working way to avoid problems. Although this was carried out, the place where the error occurred changed, but there was no change in the content of RunError (204). Code: Text  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i #0 VerifierDisableFaultInjectionExclusionRange at :0#1 ?? at :0#2 ?? at :0#3 ?? at :0#4 ?? at :0  Quote from: dseligo on December 20, 2021, 02:48:31 pmI once had similar problem (I don't remember exact error message) because there were no printers installed. Do you use dll in your program, maybe there is access issue? Certainly calling and using 'AddClipboardFormatListener' and 'RemoveClipboardFormatListener' API of 'user32.dll'. However, I do not think that it is not installed like the printer. These codes refer to the forum post below. https://forum.lazarus.freepascal.org/index.php/topic,15488.msg225927.h tml#msg225927 Note that the referenced code makes dynamic API calls, but the behavior was the same even if the contents were changed to static API calls. Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i function AddClipboardFormatListener(Wnd: HWND): BOOL; stdcall; external 'user32.dll' name 'AddClipboardFormatListener';function RemoveClipboardFormatListener(Wnd: HWND): BOOL; stdcall; external 'user32.dll' name 'RemoveClipboardFormatListener';  I tried copying this unit file to an empty project and writing a program with minimal code, and I verified that no errors occurred. Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i unit Unit1; {$mode objfpc}{$H+} interface uses  Classes, SysUtils, Forms, Controls, Graphics, Dialogs, ClipboardListener,  StdCtrls, Clipbrd; type   { TForm1 }   TForm1 = class(TForm)    ListBox1: TListBox;    procedure FormCreate(Sender: TObject);    procedure FormDestroy(Sender: TObject);  private    CL: TClipboardListener;    procedure ClipboardChanged(Sender: TObject);  public   end; var  Form1: TForm1; implementation {$R *.lfm} { TForm1 } procedure TForm1.FormCreate(Sender: TObject);begin  CL:=TClipboardListener.Create;  CL.OnClipboardChange:=@ClipboardChanged;end; procedure TForm1.FormDestroy(Sender: TObject);begin  CL.Free;end; procedure TForm1.ClipboardChanged(Sender: TObject);begin  ListBox1.Items.Add(Clipboard.AsText);end; end.  Quote from: jamie on December 20, 2021, 05:03:51 pmHave tried to compile using external debug file? I asked this earlier and didn't see any response tobit The exe file can get very large due to the attached debug file. U could have some resource size issue and I see u are using a script manager I'm not using an external debug file. I'm also trying both the debug function of Lazarus when enabled and when not. ---------------------------------------------------------------------- CCRDude · 2021-12-21 08:41 It takes some time, but there are two standard ways to go: Stepping through all code, including unit initializations, using F7"Disabling" (commenting out) all initialization code (not just in units, but also all FormCreate/FormShow/FormActivate/Create on the form) and step by step re-adding it AddClipboardFormatListener is something typical to look for by security software, since any kind of simple password stealer might use that. Add a few other criteria (unsigned, recently changed due to recompile), and it might easily trigger some bad heuristics. I would move AddClipboardFormatListener from FormCreate to the first call to FormActivate, because I like to have the window shown as fast as possible, and to avoid that your listbox additions happen during the creation stage. ---------------------------------------------------------------------- TakamiChie · 2021-12-22 00:55 Quote from: jamie on December 21, 2021, 10:41:56 pm I asked you twice and please read this ..  "Have you tried using an EXTERNAL debug file"?  And you reply stating you are not using a EXERNAL debug file..   The Key point in the question is to get you to use an EXTERNAL debug file to make the EXE file much shorter and from there please try to debug. I'm sorry, I didn't understand the meaning of the sentence. The problem this time is that RunError (204) occurs, and since I could not see the relationship between it and reducing the EXE size, I thought it was a translation mistake and interpreted it as a translation mistake. Also, I don't understand what it means to use an external debug file. Is it to enable the "Use external debug symbol file" option? And does it make the EXE size smaller than disabling the debugging feature itself? If using an external debug file does not reduce the EXE size rather than disabling the debugging function, the fact that the application does not start even if the debugging function is run with the debugging function disabled will prove that reducing the EXE size did not solve the problem. ---------------------------------------------------------------------- TakamiChie · 2022-01-01 14:16 Thanks for the reply. Quote from: CCRDude on December 21, 2021, 09:41:03 amI would move AddClipboardFormatListener from FormCreate to the first call to FormActivate, because I like to have the window shown as fast as possible, and to avoid that your listbox additions happen during the creation stage. Got a very good tip. Thank you. When the operation of the program was verified based on this hint, it was confirmed that the error occurred. Because the PC was initialized due to another factor of machine trouble, the final factor has been unknown, but I would like to use it as a hint for future development.