Recent

Author Topic: IDE crashes and takes so much code with it  (Read 1027 times)

Nicole

  • Hero Member
  • *****
  • Posts: 1095
IDE crashes and takes so much code with it
« on: April 30, 2025, 04:27:31 pm »
 >:(
In the last weeks, I lost code and code and code after not having saved every 2 minutes.
I make a severe mistake, which puzzles the compiler. e.g. I write one "end;" too many (see screenshot)
This is sever, yes.
But is this a reason to kill the whole IDE without giving me any chance to save it?

Below is the error message and attached a screenshot of a "lost my work again"-situation.

Code: Text  [Select][+][-]
  1. [Window Title]
  2. project_Tiger (C:\Tiger) - Lazarus-IDE v3.0
  3.  
  4. [Content]
  5. Kann Methode nicht zeigen Please fix the error shown in the message window which is normally below the source editor.
  6.  
  7. Press OK to ignore and risk data corruption.
  8. Press Abort to kill the program.
  9.  
  10. [Ok] [Abbruch]
  11. [Content]
  12. Kann Methode nicht zeigen Please fix the error shown in the message window which is normally below the source editor.
  13. Press OK to ignore and risk data corruption.
  14. Press Abort to kill the program.
  15. [Ok] [Abbruch]

Bart

  • Hero Member
  • *****
  • Posts: 5563
    • Bart en Mariska's Webstek
Re: IDE crashes and takes so much code with it
« Reply #1 on: April 30, 2025, 04:30:29 pm »
It's a CodeTools error.
(You're trying to complete some code?)
Just click OK (not Abort), you should be fine (most of the time), click Save All after that, just to be on the safe side.

Bart

440bx

  • Hero Member
  • *****
  • Posts: 5268
Re: IDE crashes and takes so much code with it
« Reply #2 on: April 30, 2025, 04:41:03 pm »
Nicole,

There is a package that will autosave your work.  That might be helpful to ensure you don't lose a significant amount of work.

Read about it at: https://forum.lazarus.freepascal.org/index.php/topic,68028.msg525335.html#msg525335

HTH.
(FPC v3.0.4 and Lazarus 1.8.2) or (FPC v3.2.2 and Lazarus v4.0rc3) on Windows 7 SP1 64bit.

Nicole

  • Hero Member
  • *****
  • Posts: 1095
Re: IDE crashes and takes so much code with it
« Reply #3 on: April 30, 2025, 08:35:46 pm »
Thank you for the link.

about autosave:
There is something which is even worse then a IDE-crashing. This is a programmer, who writes nonsense until she is stuck.
Sometimes I click somewhere and suddenly items are gone, lost, whatever. Then I click "close unit", "save?" - no, no no!



Martin_fr

  • Administrator
  • Hero Member
  • *
  • Posts: 11139
  • Debugger - SynEdit - and more
    • wiki
Re: IDE crashes and takes so much code with it
« Reply #4 on: April 30, 2025, 08:49:04 pm »
It would be good to find the cause of the crash.

Never mind what you throw at the editor or codetools (or any other part of the IDE), it may report errors but should not crash....

Unfortunately with the info given in this thread, there is nothing to find the cause.

Obviously (or maybe not obvious, but still) it hasn't happen to members of the dev team. They would have likely had reported it (among the team) with at least a stack trace. I am not aware of such a report.

Also not aware of anyone else reporting it. So whatever it is, it may be bound to something particular in your setup, and that may mean that it can only be fixed with help from your side.



For starters it would be good if you could build the ide with the following options in
Tools > Configure build IDE
Code: Text  [Select][+][-]
  1. -gw -gl -Criot

Then run the IDE with
Code: Text  [Select][+][-]
  1. --debug-log=c:\lazarus\log.txt
(or whatever path is appropriate for your setup)

After a crash, the file would very hopefully contain a stacktrace (among lots of other stuff).

That stacktrace may be helpful, at least for an initial hint where to go looking further.



Additionally it may be good to take a backup of your "primary config path"
Menu: view > ide internals > about IDE
It will have files like codetoolsoptions.xml and environmentoptions.xml and editoroptions.xml.
Those may be important if the error is bound to specific settings.

Backing up the folder makes sure they will be avail, should it turn out that they are needed.



Last but not least (actually should be first)

What version of Lazarus are you using?

Your OS seems Windows? If you don't mind which version and 32/64bit?

And, what packages do you have installed?
(IIRC should be listed in staticpackages.inc in the primary conf dir)


Nicole

  • Hero Member
  • *****
  • Posts: 1095
Re: IDE crashes and takes so much code with it
« Reply #5 on: May 02, 2025, 09:30:28 pm »
If I would be able to reproduce, I would do.
This "start with", it is too much to me.
I am no programmer, code-writing is just a need-fulfilling, because I need a function I cannot buy anywhere.

However I will do my best, to help the community, which gave me that much:
My Lazarus is 3.0
It runs under a Win 7 VM, 64 bit.

Attached are 2 files:
a) the file you mentioned
b) a really strange thing of an warning. The translation to English means: "Warning, double files". I deleted them often, but the next test there are there again.
I have no idea, what this means. Usually ambiguity rarely means a good thing. And the file the message mentions, I cannot find it.

CharlyTango

  • Full Member
  • ***
  • Posts: 115
Re: IDE crashes and takes so much code with it
« Reply #6 on: May 03, 2025, 11:09:03 am »
Over the years, more and more safety functions have been built into every car. And yet serious, even fatal accidents still happen.

It's no different in IT, which is why a staggered backup strategy is used at the latest after a vital crash.

Everyone has their own ideal solution.
For example, I have the code in a directory that is synchronised with a private cloud. The moment the file changes on the disc, it is copied to the cloud as a primary backup.
Since this cloud also has the option of managing different versions of a file, this is already a
pretty basic solution.

I also use a version control system that is triggered manually to keep versions together.

To keep this performant, all object files are stored in a different directory.

Unit Output Directory:
C:\Laz_Lib\<projectname>\$(TargetCPU)-$(TargetOS)-$(LazVer)

In addition, there are at least 2 (in my case with all test installed versions rather 12) complete Lazarus installations.

If it really kills my IDE, I have at least one other working installation ready with which I can continue working while the faulty instance is deleted and reinstalled in the background.

Of course, this doesn't help against all events, but it does help against a large part of them

Lazarus stable, Win32/64

Martin_fr

  • Administrator
  • Hero Member
  • *
  • Posts: 11139
  • Debugger - SynEdit - and more
    • wiki
Re: IDE crashes and takes so much code with it
« Reply #7 on: May 03, 2025, 11:51:32 am »
I don't know all the packages you have installed. Though at first sight non is particular suspicious. Yet, even the best code can crash. => So they need to be considered as potentially being the cause for the crash (as does the rest of the IDE).

But from the given data, I can't really tell anything. There are a million lines of code in the IDE, and any of them could be the culprit.

1) You can upgrade (4.0 is due soon). If you are lucky it goes away.
Even Lazarus 3.8 may be worth a shot. But now you might wait, as 4.0 is around the corner.

There are 18 commits between 3.0 and 3.8 that explicitly fix some crash (there may be more, but they don't include the word crash in the message). Not all of them are happening on Windows. But 2 or 3 do.

2) If not, then a trace is needed (or at least its the simplest way of getting any further clue.

You already rebuild your IDE for the packages you added. So no magic there.
- Make a copy of your current "lazarus.exe" (c:\lazarus\lazarus.exe or where ever you installed yours). So you can always restore this, if needed.
- Open the "Tools" menu, go to "Configure build lazarus". There is a text field (memo) "Options". Add (without the quotes): " -O-1 -gw -gl -Criot ". Then press build
- Restart the IDE
- Close the IDE
- On Windows: Create a shortcut on the desktop, and right click it, and choose "properties". In the field "target" it gives the path+name of the exe, add (with a leading space)  --debug-log=c:\lazlog.txt

Now you can start the IDE via that shortcut.
If it hasn't crashed, then occasionally (before starting) remove the old logfile. (or it will grow really large).
When it has crashed, submit the logfile (or the last 200 lines, if it is to large / or zip it).


Nicole

  • Hero Member
  • *****
  • Posts: 1095
Re: IDE crashes and takes so much code with it
« Reply #8 on: May 03, 2025, 01:34:17 pm »
Thank you.
I was not aware, there is 3.8. I thought 3.4 would be the lastest.
I'll wait for 4.

My plans are to leave Windows. There is a lot of code to write as I will have to substitute a whole software packed I bought years ago, which never will work with Wine. Then I will start with Linux and Lazarus 4. Cross fingers, it is not 5 in the meanwhile.

Nicole

  • Hero Member
  • *****
  • Posts: 1095
Re: IDE crashes and takes so much code with it
« Reply #9 on: May 06, 2025, 09:20:27 pm »
@ Martin_fr

I thought over it.
If you do not experience problems, then I suspect it is due to a working habit. Probably I use anything of copy, paste, fix names, add,.... which is not in your workflow.

In other words: What may cause troubles is the graphic environment of the IDE on work in progress. My idea would be: teach the IDE to send you an error report on unplanned ending at development time.

A very weak position are begin and end and lost headers.
Under old Delphi I once searched for loooong for an extremely unpleasant bug. It took me an eternity to find it. It was nothing but a ";" too many, lost in some unit head part.

Just one sign for a man, an intersection for a compiler.  8-)


Martin_fr

  • Administrator
  • Hero Member
  • *
  • Posts: 11139
  • Debugger - SynEdit - and more
    • wiki
Re: IDE crashes and takes so much code with it
« Reply #10 on: May 06, 2025, 09:41:05 pm »
We don't have an automatic error upload.

And not every user would want that. In fact some user would not be able to use an IDE that did this, because automatic uploads may contain private data, and some people work on company secrets.

Also, such an uploader may not always work, if the crash is to bad, and skips it.

What we have is the ability to write logfiles, that most often contain a first clue. I gave you details on how to do that.
Takes less than 10 minutes to setup
- Menu: Tools > Configure build IDE: with custom options   -O-1 -gw -gl -Criot
- 1 to 4 minutes for the IDE to rebuild
- exit IDE
- 1 to 2 minutes to create and edit the desktop shortcut
- Start working, until crash
- 1 minute to zip and upload the file

----------
Btw 4.0 is out, and avail for download.

Nicole

  • Hero Member
  • *****
  • Posts: 1095
Re: IDE crashes and takes so much code with it
« Reply #11 on: May 07, 2025, 09:18:59 pm »
Yes, this is true.
There are a lot of private data in my code as well. E.g. my authorization keys for several quite expensive services.
Now, as you say it...

Thank you for the instruction, I saved them.

munair

  • Hero Member
  • *****
  • Posts: 838
  • compiler developer @SharpBASIC
    • SharpBASIC
Re: IDE crashes and takes so much code with it
« Reply #12 on: May 10, 2025, 09:05:44 am »
I'm amazed to read this. I have been coding for years, even large projects and I can't remember Lazarus crashing on me, certainly not in recent years. And quite often I make mistakes angering code tools. Just wondering, could this be an OS issue? I've been doing most of the coding on Linux (Debian and Manjaro) using GTK2 and Lazarus seems quite stable there. I'm also in the bad habit of hitting ctrl+s frequently. But that's because I'm more afraid of sudden power outage.
It's only logical.

 

TinyPortal © 2005-2018