Lazarus IDE crashes ( Due to 'my' fiddling ) lazarus / 13-General ---------------------------------------------------------------------- Aruna · 2025-07-07 13:00 Hello Everyone, long story short I was experimenting trying to get a top-root level menu working and did manage to finally get things working with some help from chatGPT. Later, I realized some of the code GPT generated was not required so started commenting out line by line and reinstalling the package.Everything went well until at one point this happened below: 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 aruna@debian:~/lazarus$ ./lazarus --pcp=/home/aruna/lazarusSetPrimaryConfigPath NewValue="/home/aruna/lazarus"Hint: (lazarus) [TMainIDE.ParseCmdLineOptions] PrimaryConfigPath="/home/aruna/lazarus"Hint: (lazarus) [TMainIDE.ParseCmdLineOptions] SecondaryConfigPath="/etc/lazarus"FreeFormEditor: FormEditor1=TFormEditorHint: (lazarus) [TMainIDE.Destroy] B  -> inherited Destroy... TMainIDEHint: (lazarus) [TMainIDE.Destroy] END[FORMS.PP] ExceptionOccurred   Sender=EAccessViolation  Exception=Access violation  Stack trace:  $0000000000ACB575  ADD,  line 1986 of idecommands.pas  $0000000000AC88B2  USERADDED,  line 1344 of idecommands.pas  $0000000000ACAB67  SETCOMMAND,  line 1835 of idecommands.pas  $0000000000AD807C  SETCOMMAND,  line 643 of menuintf.pas  $0000000000AD7AF4  REGISTERIDEMENUCOMMAND,  line 536 of menuintf.pas  $000000000160FFAA  REGISTER,  line 47 of mytopmenudemo.pas  $0000000000C355BB  CALLREGISTERPROC,  line 6123 of packagesystem.pas  $0000000000C20279  REGISTERUNITHANDLER,  line 2035 of packagesystem.pas  $0000000000C55CC0  REGISTERUNIT,  line 124 of lazaruspackageintf.pas  $00000000004DEF57  REGISTER,  line 17 of newpackage.pas  $0000000000C355BB  CALLREGISTERPROC,  line 6123 of packagesystem.pas  $0000000000C3555C  REGISTERSTATICPACKAGE,  line 6105 of packagesystem.pas  $0000000000C3DA8D  LOADSTATICCUSTOMPACKAGES,  line 1561 of ../packager/pkgmanager.pas  $0000000000C436BA  LOADINSTALLEDPACKAGES,  line 3044 of ../packager/pkgmanager.pas  $00000000004AA0F8  CREATE,  line 1675 of main.pp  $000000000042176F  main,  line 144 of lazarus.ppTApplication.HandleException: EAccessViolationAccess violation  Stack trace:  $0000000000ACB575  ADD,  line 1986 of idecommands.pas  $0000000000AC88B2  USERADDED,  line 1344 of idecommands.pas  $0000000000ACAB67  SETCOMMAND,  line 1835 of idecommands.pas  $0000000000AD807C  SETCOMMAND,  line 643 of menuintf.pas  $0000000000AD7AF4  REGISTERIDEMENUCOMMAND,  line 536 of menuintf.pas  $000000000160FFAA  REGISTER,  line 47 of mytopmenudemo.pas  $0000000000C355BB  CALLREGISTERPROC,  line 6123 of packagesystem.pas  $0000000000C20279  REGISTERUNITHANDLER,  line 2035 of packagesystem.pas  $0000000000C55CC0  REGISTERUNIT,  line 124 of lazaruspackageintf.pas  $00000000004DEF57  REGISTER,  line 17 of newpackage.pas  $0000000000C355BB  CALLREGISTERPROC,  line 6123 of packagesystem.pas  $0000000000C3555C  REGISTERSTATICPACKAGE,  line 6105 of packagesystem.pas  $0000000000C3DA8D  LOADSTATICCUSTOMPACKAGES,  line 1561 of ../packager/pkgmanager.pas  $0000000000C436BA  LOADINSTALLEDPACKAGES,  line 3044 of ../packager/pkgmanager.pas  $00000000004AA0F8  CREATE,  line 1675 of main.pp  $000000000042176F  main,  line 144 of lazarus.pparuna@debian:~/lazarus$    I have found a work-aroudn and have managed to get the IDE back to life but all the docks are gone to hell so I have to reinstall anchordocking and friends. I was wondering is there a way to fix this without jumping through hoops and loops? Strange thing is my unit is no longer there even in the backup folder. If the stack trace makes any sense to anyone more familiar and experienced please do show me what to do? Screenshot attached for reference. EDIT: I ran make bigide and teh docking resurrected and so did my unit. Unit is below: 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 MyTopMenuDemo; {$mode objfpc}{$H+} interface uses  Classes, SysUtils, Dialogs,  MenuIntf, IDECommands, Menus; procedure Register; implementation type  TMyMenuHandler = class    procedure OnMyMenuClick(Sender: TObject);  end; var  MenuHandler: TMyMenuHandler; procedure TMyMenuHandler.OnMyMenuClick(Sender: TObject);begin  ShowMessage('Hello from my top-level menu!');end; procedure Register;var  MyMenuItem: TMenuItem;  MyCommand: TIDECommand;  Cat: TIDECommandCategory;begin  MenuHandler := TMyMenuHandler.Create;   // Create menu item  MyMenuItem := TMenuItem.Create(nil);  MyMenuItem.Caption := 'MyTopMenu';  // What user sees   // Find Tools category//  Cat := IDECommandList.FindCategoryByName(CommandCategoryToolMenuName);   // Register IDE command  //MyCommand := RegisterIDECommand(Cat, 'MyTopCommand', 'Show Message', @MenuHandler.OnMyMenuClick);   // Register menu command in our root menu  RegisterIDEMenuCommand(mnuMain, 'MyTopCommand', 'Say Hello', @MenuHandler.OnMyMenuClick, nil, MyCommand);end; end. ---------------------------------------------------------------------- Aruna · 2025-07-07 13:43 Screenshot shows top-level added menu and on-click showmessage. Is what I have done acceptable or there are better ways to do this? I went through the ideintf.pas and  menuintf.pas to get the required commands. 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 aruna@debian:~/lazarus/components/ideintf$ ls -1 *intf.pasformeditingi ntf.pasidedebuggervalueformatterintf.pasidedebuggerwatchvalueintf.pasi dehelpintf.pasideimagesintf.pasideintf.pasidemsgintf.pasideopteditorin tf.pasidewindowintf.paslazideintf.pasmenuintf.passrceditorintf.pastool barintf.pasaruna@debian:~/lazarus/components/ideintf$   I noticed some of the commands are not documented in the wiki? Maybe I will write up something in the wiki with complete units? ---------------------------------------------------------------------- JuhaManninen · 2025-07-07 20:44 MyCommand is not initialized in your code example. It contains garbage. I don't know why it destroyed your whole Lazarus so badly. Usually there is a dialog telling about the access violation but then the IDE remains usable. ---------------------------------------------------------------------- Aruna · 2025-07-08 01:45 Quote from: JuhaManninen on July 07, 2025, 10:44:37 pmMyCommand is not initialized in your code example. It contains garbage I don't know why it destroyed your whole Lazarus so badly. Usually there is a dialog telling about the access violation but then the IDE remains usable. Yes, I commented out the initialization line when testing which was a very bad idea because after doing that and asking the ide to rebuild itself it tried and did show the access violation error message which I posted a screenshot of earlier but left my poor IDE in a non-usable state. (Easily fixed by running make bigide.) ---------------------------------------------------------------------- Joanna · 2025-07-08 02:21 Try again without using chat gpt ---------------------------------------------------------------------- Thaddy · 2025-07-08 04:11 No that is fine to get you going although it makes mistakes. Ask the same question to DeepSeek (in deep mode, left blue button) and see what that comes up with. The nice thing about deepseek is that you can follow its reasoning step by step, which is a great feature. (And it is rather good at Freepascal) You can subsequenty feed it back in chatgpt to have it evaluated  and the other way around. Both AI models are best when used interactively. Both can also solve their own errors if you point them out. DeepSeek often does the better job. chatGPT uses more of general programming concepts, DeepSeek tries to follow the compiler logic for the FPC compiler even the compiler version! It also makes mistakes but in an interactive session you can usually make it work close to what you mean. CoPilot may also help, although that is based on chatGPT technology, the model is different. Note in any case, if you want to use these AI models you still need to be a reasonably good programmer but you are a good programmer. ---------------------------------------------------------------------- Joanna · 2025-07-08 08:43 It’s like giving a child who can’t swim a raft for deep water ---------------------------------------------------------------------- Thaddy · 2025-07-08 09:02 No, just inflatable sleeves ---------------------------------------------------------------------- Martin_fr · 2025-07-08 09:38 Nice bit of fun entertainment. Please don't forget to return to the original topic. I.e. Moderation note: Further swimming instructions, would be off topic.