Recent

Author Topic: Lazarus IDE crashes ( Due to 'my' fiddling )  (Read 2037 times)

Aruna

  • Hero Member
  • *****
  • Posts: 807
Lazarus IDE crashes ( Due to 'my' fiddling )
« on: July 07, 2025, 03:00:20 pm »
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][+][-]
  1. aruna@debian:~/lazarus$ ./lazarus --pcp=/home/aruna/lazarus
  2. SetPrimaryConfigPath NewValue="/home/aruna/lazarus"
  3. Hint: (lazarus) [TMainIDE.ParseCmdLineOptions] PrimaryConfigPath="/home/aruna/lazarus"
  4. Hint: (lazarus) [TMainIDE.ParseCmdLineOptions] SecondaryConfigPath="/etc/lazarus"
  5. FreeFormEditor: FormEditor1=TFormEditor
  6. Hint: (lazarus) [TMainIDE.Destroy] B  -> inherited Destroy... TMainIDE
  7. Hint: (lazarus) [TMainIDE.Destroy] END
  8. [FORMS.PP] ExceptionOccurred
  9.   Sender=EAccessViolation
  10.   Exception=Access violation
  11.   Stack trace:
  12.   $0000000000ACB575  ADD,  line 1986 of idecommands.pas
  13.   $0000000000AC88B2  USERADDED,  line 1344 of idecommands.pas
  14.   $0000000000ACAB67  SETCOMMAND,  line 1835 of idecommands.pas
  15.   $0000000000AD807C  SETCOMMAND,  line 643 of menuintf.pas
  16.   $0000000000AD7AF4  REGISTERIDEMENUCOMMAND,  line 536 of menuintf.pas
  17.   $000000000160FFAA  REGISTER,  line 47 of mytopmenudemo.pas
  18.   $0000000000C355BB  CALLREGISTERPROC,  line 6123 of packagesystem.pas
  19.   $0000000000C20279  REGISTERUNITHANDLER,  line 2035 of packagesystem.pas
  20.   $0000000000C55CC0  REGISTERUNIT,  line 124 of lazaruspackageintf.pas
  21.   $00000000004DEF57  REGISTER,  line 17 of newpackage.pas
  22.   $0000000000C355BB  CALLREGISTERPROC,  line 6123 of packagesystem.pas
  23.   $0000000000C3555C  REGISTERSTATICPACKAGE,  line 6105 of packagesystem.pas
  24.   $0000000000C3DA8D  LOADSTATICCUSTOMPACKAGES,  line 1561 of ../packager/pkgmanager.pas
  25.   $0000000000C436BA  LOADINSTALLEDPACKAGES,  line 3044 of ../packager/pkgmanager.pas
  26.   $00000000004AA0F8  CREATE,  line 1675 of main.pp
  27.   $000000000042176F  main,  line 144 of lazarus.pp
  28. TApplication.HandleException: EAccessViolation
  29. Access violation
  30.   Stack trace:
  31.   $0000000000ACB575  ADD,  line 1986 of idecommands.pas
  32.   $0000000000AC88B2  USERADDED,  line 1344 of idecommands.pas
  33.   $0000000000ACAB67  SETCOMMAND,  line 1835 of idecommands.pas
  34.   $0000000000AD807C  SETCOMMAND,  line 643 of menuintf.pas
  35.   $0000000000AD7AF4  REGISTERIDEMENUCOMMAND,  line 536 of menuintf.pas
  36.   $000000000160FFAA  REGISTER,  line 47 of mytopmenudemo.pas
  37.   $0000000000C355BB  CALLREGISTERPROC,  line 6123 of packagesystem.pas
  38.   $0000000000C20279  REGISTERUNITHANDLER,  line 2035 of packagesystem.pas
  39.   $0000000000C55CC0  REGISTERUNIT,  line 124 of lazaruspackageintf.pas
  40.   $00000000004DEF57  REGISTER,  line 17 of newpackage.pas
  41.   $0000000000C355BB  CALLREGISTERPROC,  line 6123 of packagesystem.pas
  42.   $0000000000C3555C  REGISTERSTATICPACKAGE,  line 6105 of packagesystem.pas
  43.   $0000000000C3DA8D  LOADSTATICCUSTOMPACKAGES,  line 1561 of ../packager/pkgmanager.pas
  44.   $0000000000C436BA  LOADINSTALLEDPACKAGES,  line 3044 of ../packager/pkgmanager.pas
  45.   $00000000004AA0F8  CREATE,  line 1675 of main.pp
  46.   $000000000042176F  main,  line 144 of lazarus.pp
  47. aruna@debian:~/lazarus$
  48.  
  49.  

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][+][-]
  1. unit MyTopMenuDemo;
  2.  
  3. {$mode objfpc}{$H+}
  4.  
  5. interface
  6.  
  7. uses
  8.   Classes, SysUtils, Dialogs,
  9.   MenuIntf, IDECommands, Menus;
  10.  
  11. procedure Register;
  12.  
  13. implementation
  14.  
  15. type
  16.   TMyMenuHandler = class
  17.     procedure OnMyMenuClick(Sender: TObject);
  18.   end;
  19.  
  20. var
  21.   MenuHandler: TMyMenuHandler;
  22.  
  23. procedure TMyMenuHandler.OnMyMenuClick(Sender: TObject);
  24. begin
  25.   ShowMessage('Hello from my top-level menu!');
  26. end;
  27.  
  28. procedure Register;
  29. var
  30.   MyMenuItem: TMenuItem;
  31.   MyCommand: TIDECommand;
  32.   Cat: TIDECommandCategory;
  33. begin
  34.   MenuHandler := TMyMenuHandler.Create;
  35.  
  36.   // Create menu item
  37.   MyMenuItem := TMenuItem.Create(nil);
  38.   MyMenuItem.Caption := 'MyTopMenu';  // What user sees
  39.  
  40.   // Find Tools category
  41. //  Cat := IDECommandList.FindCategoryByName(CommandCategoryToolMenuName);
  42.  
  43.   // Register IDE command
  44.   //MyCommand := RegisterIDECommand(Cat, 'MyTopCommand', 'Show Message', @MenuHandler.OnMyMenuClick);
  45.  
  46.   // Register menu command in our root menu
  47.   RegisterIDEMenuCommand(mnuMain, 'MyTopCommand', 'Say Hello', @MenuHandler.OnMyMenuClick, nil, MyCommand);
  48. end;
  49.  
  50. end.
  51.  
« Last Edit: July 07, 2025, 03:32:54 pm by Aruna »

Aruna

  • Hero Member
  • *****
  • Posts: 807
Re: Lazarus IDE crashes ( Due to 'my' fiddling )
« Reply #1 on: July 07, 2025, 03:43:41 pm »
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][+][-]
  1. aruna@debian:~/lazarus/components/ideintf$ ls -1 *intf.pas
  2. formeditingintf.pas
  3. idedebuggervalueformatterintf.pas
  4. idedebuggerwatchvalueintf.pas
  5. idehelpintf.pas
  6. ideimagesintf.pas
  7. ideintf.pas
  8. idemsgintf.pas
  9. ideopteditorintf.pas
  10. idewindowintf.pas
  11. lazideintf.pas
  12. menuintf.pas
  13. srceditorintf.pas
  14. toolbarintf.pas
  15. aruna@debian:~/lazarus/components/ideintf$
  16.  

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

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 4715
  • I like bugs.
Re: Lazarus IDE crashes ( Due to 'my' fiddling )
« Reply #2 on: July 07, 2025, 10:44:37 pm »
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.
Mostly Lazarus trunk and FPC 3.2 on Manjaro Linux 64-bit.

Aruna

  • Hero Member
  • *****
  • Posts: 807
Re: Lazarus IDE crashes ( Due to 'my' fiddling )
« Reply #3 on: July 08, 2025, 03:45:23 am »
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.
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

  • Hero Member
  • *****
  • Posts: 1452
Re: Lazarus IDE crashes ( Due to 'my' fiddling )
« Reply #4 on: July 08, 2025, 04:21:35 am »
Try again without using chat gpt  8)

Thaddy

  • Hero Member
  • *****
  • Posts: 19262
  • Glad to be alive.
Re: Lazarus IDE crashes ( Due to 'my' fiddling )
« Reply #5 on: July 08, 2025, 06:11:56 am »
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.
« Last Edit: July 08, 2025, 06:29:41 am by Thaddy »
objects are fine constructs. You can even initialize them with constructors.

Joanna

  • Hero Member
  • *****
  • Posts: 1452
Re: Lazarus IDE crashes ( Due to 'my' fiddling )
« Reply #6 on: July 08, 2025, 10:43:19 am »
It’s like giving a child who can’t swim a raft for deep water  :D

Thaddy

  • Hero Member
  • *****
  • Posts: 19262
  • Glad to be alive.
Re: Lazarus IDE crashes ( Due to 'my' fiddling )
« Reply #7 on: July 08, 2025, 11:02:38 am »
No, just inflatable sleeves
objects are fine constructs. You can even initialize them with constructors.

Martin_fr

  • Administrator
  • Hero Member
  • *
  • Posts: 12399
  • Debugger - SynEdit - and more
    • wiki
Re: Lazarus IDE crashes ( Due to 'my' fiddling )
« Reply #8 on: July 08, 2025, 11:38:05 am »
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.

 

TinyPortal © 2005-2018