Recent

Author Topic: Random "Codetools errors"/"unit not found StdCtrls" on fresh install 2.2.6 / deb  (Read 2814 times)

NonSpillable

  • New Member
  • *
  • Posts: 10
After upgrading to Debian 12 I do as I always do and Lazarus is among the first packages I install.

The IDE works, for a moment, but behaves oddly in two ways. First, it start to throw
Codetools, Errors: 1
main.pas(8,76) Error: unit not found: StdCtrls
in the Message box. I can compile, I can run. But I cannot add things on the form and clicking on methods. It gives the warning dialog
"Unable to create new method. Please fix the error shown in the message window which is normally below the source editor. Press OK to ignore and risk data corruption. Press Abort to kill the program." (If I press "Abort" I get "Access violation")

It usually happens when code completion is "running" in the editor, and instead of showing parameters for a function (etc), the editor jumps to the "uses" line in the code and show the error.

Restarting the IDE gives me a few minutes of useful work, before it happens again. I still can compile and run when this happens.

The second problem is random high CPU utilization of bin/lazarus during idle.

Here what I've tried so far:
Removing and reinstalling via synaptic/apt.
Tools->Rescan FPC Source Directory
Tools->Rebuild Lazarus with profile (I've tried "Normal" and "Clean up + Build all")

Any suggestions? Any logs/files/outputs from me that can assist to diagnose and/or solve the problem?


Martin_fr

  • Administrator
  • Hero Member
  • *
  • Posts: 10553
  • Debugger - SynEdit - and more
    • wiki
I can just add a few guesses...

High CPU: start your lazarus from a terminal/console => then it may write debug output to the console. Maybe there is anything of interest in there.

Codetools: Have you got any 3rd party packages? Some use features of the Pascal language that codetool does not yet have (certain generics...).
Make sure you have no old files of an earlier fpc or lazarus installation.

cdbc

  • Hero Member
  • *****
  • Posts: 1663
    • http://www.cdbc.dk
Hi
I had that particular problem once...
In my case the root of the problem was a "double Free" deeply nested in my own code. But hunting for the reason always threw me deep in the implementation of lclQt?!? (the font-cache), and sometimes "uses"/"StdCtrls". Had nothing whatsoever to do with that... Errors like that can be wimsy and hard to find, that one got me at least 100 new gray hairs  :D
Regards Benny
If it ain't broke, don't fix it ;)
PCLinuxOS(rolling release) 64bit -> KDE5 -> FPC 3.2.2 -> Lazarus 2.2.6 up until Jan 2024 from then on it's: KDE5/QT5 -> FPC 3.3.1 -> Lazarus 3.0

dseligo

  • Hero Member
  • *****
  • Posts: 1411
Codetools, Errors: 1
main.pas(8,76) Error: unit not found: StdCtrls
in the Message box. I can compile, I can run. But I cannot add things on the form and clicking on methods. It gives the warning dialog
"Unable to create new method. Please fix the error shown in the message window which is normally below the source editor. Press OK to ignore and risk data corruption. Press Abort to kill the program." (If I press "Abort" I get "Access violation")

It usually happens when code completion is "running" in the editor, and instead of showing parameters for a function (etc), the editor jumps to the "uses" line in the code and show the error.

Restarting the IDE gives me a few minutes of useful work, before it happens again. I still can compile and run when this happens.

Sometimes I have the very similar problem with 2.2.6 under Windows 11, but only when creating new project.
If this happens and I add button to the form, button is created on the form, but line 'Button1: TButton;' is not inserted in unit's code.

Then I close Lazarus and start it again. After that it all works (unlike your problem - it works only for a few minutes for you).

Martin_fr

  • Administrator
  • Hero Member
  • *
  • Posts: 10553
  • Debugger - SynEdit - and more
    • wiki
In general terms, there is a know issue ("know" as in "has been observed", but not "why it happens").

This issue does cause such random errors, but usually only once in a very long time (once a month, if using the IDE daily). This issue has been around for many years (and despite various efforts the reason has not been found).

For it to happen every few minutes is new / different. => It most likely means that you have a source/pascal file somewhere, either in the wrong place, or with new fpc syntax that isn't supported by codetools.

Or you have some package installed in your IDE that is broken (could be any random package, totally unrelated to codetools and sources). If that package has a bug and causes memory to be incorrectly changed.



Or you recompiled your IDE with settings that trigger a bug in FPC.
Unfortunately the current released FPC (3.2.2) has some such bugs.

Rebuild your IDE with -O-1  and see if that improves anything.
(This is only if you did rebuild / e.g. when installing packages)

NonSpillable

  • New Member
  • *
  • Posts: 10
I can just add a few guesses...

High CPU: start your lazarus from a terminal/console => then it may write debug output to the console. Maybe there is anything of interest in there.

Codetools: Have you got any 3rd party packages? Some use features of the Pascal language that codetool does not yet have (certain generics...).
Make sure you have no old files of an earlier fpc or lazarus installation.
Good advice. I did run from the terminal, but I wasn't focused on the CPU thing then, just the "codetool" issue, which was hurting my workflow.

I did have LazSerial installed (one the first packages I usually add) but after a clean install after deleting all traces of Lazarus I decided to try it without any extra packages and just opened a project that can compile and run without any external components. And, at first it seemed to work, but I triggered the problem soon enough. The steps are inconsistent, but usually is to first compile (not run), then place something on a form and clicking it to create a method. Then in the method, just write something that bring up code completion such as "val(". Then do this a few times, compiling, adding, writing something that triggers suggestions, and after any steps the problem occurs. I never need to run my programs, just fooling around in the IDE:

Anyhow, since this was hurting my productivity so bad (even if it still compiles and run, the caret often jumps to the "uses" lines at the top of the project, so I constantly get startled) that I called it quits and installed an older version (2.2.2) and I've used it the whole day without problems (and installing LazSerial).

Hi
I had that particular problem once...
In my case the root of the problem was a "double Free" deeply nested in my own code. But hunting for the reason always threw me deep in the implementation of lclQt?!? (the font-cache), and sometimes "uses"/"StdCtrls". Had nothing whatsoever to do with that... Errors like that can be wimsy and hard to find, that one got me at least 100 new gray hairs  :D
Regards Benny
That's interesting, because it seems to be a wholly other "way" into the issue. I don't even need to run my own code, just open the project and "fooling around" with things on the form, writing things that triggers auto completion-suggestions or parameter lists. I can just start a new project and "adding stuff" without ever running it (so it's code that have never ever ran). I DO seem to need to compile it, but running is not necessary. So an double free on my part is, well, not the reason. But still interesting, as it may indicate some common cause in memory handling.

I have maybe another symptom I forgot to mention yesterday (didn't connect the two). When I open a project (old or created in 2.2.6) I sometimes get a message about the debugger. Something like "wasn't compiled with Ddwarf gtk2" (I didn't pay much attention and it just happens once per project it seems). Related?

In general terms, there is a know issue ("know" as in "has been observed", but not "why it happens").

This issue does cause such random errors, but usually only once in a very long time (once a month, if using the IDE daily). This issue has been around for many years (and despite various efforts the reason has not been found).

For it to happen every few minutes is new / different. => It most likely means that you have a source/pascal file somewhere, either in the wrong place, or with new fpc syntax that isn't supported by codetools.

Or you have some package installed in your IDE that is broken (could be any random package, totally unrelated to codetools and sources). If that package has a bug and causes memory to be incorrectly changed.



Or you recompiled your IDE with settings that trigger a bug in FPC.
Unfortunately the current released FPC (3.2.2) has some such bugs.

Rebuild your IDE with -O-1  and see if that improves anything.
(This is only if you did rebuild / e.g. when installing packages)
Okay, I may try this and investigate further in the future. Maybe I should have asked earlier (have battling with this a week) or not given up so soon after creating the thread, but I got so annoyed that I installed 2.2.2 (from SourcheForges .deb packages) and it seems to work without issues. The 2.2.6 version is "stock" from Debians repos. That made me so confused. I mean, I have had lazarus IDE problems before, but often there has been some tinkering first from my part with versions, packages, custom installs and whatnot. But this time it was just "apt-get install lazarus" and nothing more.

I shall do a mental note of this thread and promise to come back and check it and/or add info if I do new brave attempt at 2.2.6!

My sad and cowardly solution so far, downgrading, seems to work.

Thanks everyone for replies, even tho I chickened out! I usually expect no replies for my problems often seem so odd or unique (and English isn't my first language, so it's an effort to write).
« Last Edit: August 10, 2023, 11:35:30 pm by NonSpillable »

Thaddy

  • Hero Member
  • *****
  • Posts: 16184
  • Censorship about opinions does not belong here.
Errors are never random. They have a cause. Always programmer error.
Op. Cit. Hamlet again.
https://www.enotes.com/shakespeare-quotes/there-more-things-heaven-earth-horatio
« Last Edit: August 11, 2023, 07:55:28 am by Thaddy »
If I smell bad code it usually is bad code and that includes my own code.

NonSpillable

  • New Member
  • *
  • Posts: 10
Errors are never random. They have a cause. Always programmer error.
Op. Cit. Hamlet again.
https://www.enotes.com/shakespeare-quotes/there-more-things-heaven-earth-horatio
Or HW issues.

Anyway, everyone knows errors always have causes. That doesn't make random errors non-random since random doesn't mean "without cause" (and no, we don't need any cleverness about say Copenhagen interpretation of quantum mechanics). I was kind of pleased by someone knowing this was a somewhat known issue as this at least rules out a completely different problem with completely different application being together with the IDE issue in a more systemic problem with the computer and/or OS. Everything here is new, and I always let trust in the computer and OS build over time so when problem arrives with a new setup, new installed OS and a new installed application, it's easy to start casting wide nets and running memtest86, prime95 and such for hours in order to rule out HW issues than looking for specific problems with the specific application. As I said before, I was a bit late to start this thread since I've thrown away much time in "wide net" searches because my computer is new. And it simply could not be my own code, since my program never needs to run (or be anything other a default form with a button) and the LazSerial package was ruled out too.

Second day of 2.2.2, no hint of any problems yet, everything seems fine.

BrunoK

  • Hero Member
  • *****
  • Posts: 623
  • Retired programmer
Are you sure you didn't introduce some (involontary) error in the lazarus source code.

See Topic Ctrl-click is not working for some projects, https://forum.lazarus.freepascal.org/index.php/topic,63820.0.html

Thaddy

  • Hero Member
  • *****
  • Posts: 16184
  • Censorship about opinions does not belong here.
As I wrote: "Random errors" do not exist. (Are not supposed to) That does not mean that the  end user made the error, it means that the complete package of code contains an error. That may have been caused by you or may have been caused deep inside libraries or the compiler itself.
If I smell bad code it usually is bad code and that includes my own code.

 

TinyPortal © 2005-2018