Lazarus

Free Pascal => Beginners => Topic started by: JLWest on December 01, 2019, 05:28:54 am

Title: Bug I think.
Post by: JLWest on December 01, 2019, 05:28:54 am
I have two items that have happened I'm not sure of?

The first one was an exception raised saying I was out of memory. I find that difficult to believe with 32GB of memory. At the time I was adding some code to my program in the IDE.

The second one was the creation of a ton (15 or 20  empty procedures matching valid procedures I have in the program. It duplicated only procedures, no functions.

Took over an hour to clean it up.

Example: The following was created somewhere up in the Unit1.

procedure TForm1.btnCloseClick(Sender: TObject);
  begin

  end;   

 I do have a procedure TForm1.btnCloseClick(Sender: TObject);

It's the last procedure in my program.

I have tried to duplicate the issue but didn't succeed. If it happens again I would be willing to post my code.



Title: Re: Bug I think.
Post by: winni on December 01, 2019, 05:47:00 am
Hi

That sounds realy strange!!

But what I would do anyway is

tools --> editor --> completition and  hints  -- > Auto remove  empty methods

And then a courageous SAVE  and all the empty procedure should vanish.

Winni
Title: Re: Bug I think.
Post by: JLWest on December 01, 2019, 09:09:33 am
It's that "courageous SAVE" that get's your attention.

Thanks' I'll try it. (Maybe)
Title: Re: Bug I think.
Post by: PaulRowntree on December 04, 2019, 06:00:36 am
You can always copy the text to the clipboard before the 'courageous save', and recover if needed.
Title: Re: Bug I think.
Post by: Martin_fr on December 04, 2019, 10:24:15 am
Or instead: Context menu in the editor > refactoring > empty methods

Anyway: no explanation as to why they appear in the beginning
Title: Re: Bug I think.
Post by: JLWest on December 04, 2019, 03:33:56 pm
No, I can't figure it out or reproduce it. It happens after a compile.

I think the steps are something like this.

I'm in the debugger step tracing a program and I notice something wrong. I correct it, (change some text or add a few lines of code).
Do a Run>Build and get the message Stop the debugger. Answer yes and build the program.
 
Title: Re: Bug I think.
Post by: jamie on December 04, 2019, 11:52:56 pm
Not smart to have the program still running and in debugging process while you edit your program.

 I can see all kinds of things going wrong there.
Title: Re: Bug I think.
Post by: winni on December 05, 2019, 12:11:54 am
@JLWest

That is dangerous what you do!

When you did it in (very) old versions you suddenly had two versions of your code and the IDE ask you which one to use!!  Perhaps there are some loose ends of this code still present.

So: Run --> Stop   as first action.
And then start to edit! Perhaps it solves your problem.

Winni
Title: Re: Bug I think.
Post by: Martin_fr on December 05, 2019, 01:04:48 am
Not smart to have the program still running and in debugging process while you edit your program.

 I can see all kinds of things going wrong there.

Lazarus fully supports editing your sources while you debug. That should be fine.

I do that all the time.
Even with big projects, like the IDE itself.
Title: Re: Bug I think.
Post by: Martin_fr on December 05, 2019, 01:13:39 am
The second one was the creation of a ton (15 or 20  empty procedures matching valid procedures I have in the program. It duplicated only procedures, no functions.

This is rather strange.

Normally codetools would insert procedures, but only if they were missing.

There is an issue, with property getter though, that even if the exist for fpc, if you changed the syntax (not sure what it was, maybe added () after the name), then codetools would duplicate them (but also in the declaration).

I am not the codetool expert. Sometimes it gets stuck parsing sources. Then it could be blind to existing code. But I am not sure it would then insert anything.
Also that would mean "all procedures and functions up to line x", not just procedures.

Did the procedures have other stuff in common? E.g. maybe they where events on the form. Maybe all events where recreated? (again should not happen, but...).



I suppose the clean up was so tedious, because you only noticed later. And maybe already edited other stuff?

Or did you try "Undo", and undo did not work?

Should it happen again:
- Save
- Undo, until you reach the point where it happened.
- try to remember what you did then.
  Create an event from the OI or form designer?
  run codecompletion ctrl-shift c
   something else?

This may be a start.

Title: Re: Bug I think.
Post by: six1 on December 05, 2019, 07:48:07 am
...i can confirm this.
Never had an "out of memory" error before.
Laz 2.0.6 r62129 build up with fpcupdeluxe under WIN10/64

it occurs a few time last 14 days and i'm not able to specify why this happens nor an exact actions what it triggers.

- i deleted an Object from a form -> crash
- i edited Source and while i do this --> "out of memory" and windows are flying away. had to kick out lazarus  of win process list (happend a few times)

sorry, i can't specify anyting more, but if this happens, i'm not able to investigate anything and trigger seams to be different each time


on the other hand, i've same laz fpc installation on a VM Debian10/64 without errors. For me it seams to only happen on windows...
very obfuscated...


Edit:
in addition: Project never had this sort of problem in Laz 2.0.2
Title: Re: Bug I think.
Post by: marcov on December 05, 2019, 07:56:05 am
This errror is Delphi compatible. Delphi suffers even more from this.

It happens when for some minor syntactic error, complete gets triggered and the IDE parser can't recognize the methods. So it adds new empty ones.

Delphi is worse since it stumbled on many things (like ifdefs inside constructs like a property declaration), while lazarus doesn't.
Title: Re: Bug I think.
Post by: Martin_fr on December 05, 2019, 05:35:57 pm
Ok, let assume (and that is a big assumption) it is codetool related (just because inserting methods in the code usually is)....

Lots of us have not encountered the issue, maybe it is just that rare, maybe it only happens if certain pascal features occur in the sources.

If it is the latter, then the question is: those who experience the issue, what have they in common (other than bad luck ;) )

I looked through the commit messages related to codetool in fixes since 2.0.2. While none of them is outstanding, there are 2 commits that refer to none-everyday-features: generics and "advanced records"

So are they used in the projects, that leads to the error?


The other approach:
- Make sure your IDE is compiled with debug info
- Always start your IDE in gdb
  Make a small script (needs to run in a terminal), probably: gdb.exe -ex r lazarus.exe

Then when it crashes, do "bt" in gdb.

Title: Re: Bug I think.
Post by: JLWest on December 05, 2019, 08:12:31 pm
@Martin_fr

"Did the procedures have other stuff in common? E.g. maybe they where events on the form. Maybe all events where recreated? (again should not happen, but...)."

I Didn't notice but no there was definitely an empty Close procedure.

Here is a better step by step:

I'm in the debugger stepping thru a program. I change a line of code or add a few lines, sometimes I add a procedure or function.

The I forget the debugger is running - I do a Run>Build and get the message 'Hey dummy the debugger is running What do you want to do with it; I stop the debugger fro the modal window and I think my program builds. And that's when I get all the empty procedures.  So I usually make a backup of the code. Then I scroll down thru the Unit1 and delete empty
procedures.

@Jamie

It's handy to make code changes this way. In my case with poor eye sight, I have Local and Watch windows open and can see all the variables and values. Most of the time it's just a quick change of something.

     
Title: Re: Bug I think.
Post by: Martin_fr on December 05, 2019, 10:54:22 pm
I'm in the debugger stepping thru a program. I change a line of code or add a few lines, sometimes I add a procedure or function.   

I did see that. The question is which of those steps are really involved in triggering the issue.

I do a lot of editing during debugging (and occasionally have to answer that dialog). Though I mostly edit units without forms. But I never had the issue.

I do not think it is the "during debugging". Afaik there is nothing different during debugging, than when the debugger is off.
Though the "do you want to stop" may affect any work that is done at that time (since obviously code flow in the IDE is altered).
The only think I can think is happening there, is
- files will be saved (I think an unlikely candidate)
- "remove empty procedure" is executed if enabled
I do not have the latter enabled, so if that were involved, it would explain why I do not get this.

Not sure what else codetools (we are talking auto generated code) would do, that is affected by any of those things.
However codetool is easily affected by the sources themself. Any particular coding style can trigger a bug.
IIRC, if the getter/setter for a property is in a parent class, or has extra brackets, then it will be duplicated (but only if codecompletion is explicitly triggered)

Anyway any other source code in your units, that would seem totally normal, compiles fine and all, could be behind this.
Yet again, the strange part is, that normally if codetool gets upset, it will refuse to insert any code at all "the component editor ... error", or codecompletion errors.....

The problem is that you notice the error when you try to compile. But that does not say it was introduced at that time. It could have been introduced seconds after the previous compile, or any time inbetween.
Hence my idea to use the undo function, and see where in your editing flow the errors where created.
Its a long shot, but maybe it reveals something.
Title: Re: Bug I think.
Post by: JLWest on December 06, 2019, 01:02:24 am
OK I'll try the UNDO, when it happens again.
Title: Re: Bug I think.
Post by: Martin_fr on December 06, 2019, 02:21:36 am
Also maybe one more thing.

Before you do anything:
Switch to the unit, if not already there (active editor)
Menu > View > IDE Internals > Show CodeTool Node Info
Copy the data from each of the tabes

Then save the file.
Then undo

I personally can't do anything with that node info, but Mattias may need it....
Title: Re: Bug I think.
Post by: JLWest on December 06, 2019, 04:14:50 am
"Martin_fr


Menu > View > IDE Internals > Show CodeTool Node Info

Menu > View > IDE Internals > About FPC
                                              About IDE
                                              What Needs Building
                                              Debug Options

I think you mean Debug Options, Please confirm
Title: Re: Bug I think.
Post by: Martin_fr on December 06, 2019, 05:46:41 am
No I mean "show Codetool node info". Mattias will hopefully confirm.

"debug output" is the gdb communication. That only helps if gdb does the wrong thing. gdb definitely does not mess with the editor content.

Title: Re: Bug I think.
Post by: JLWest on December 06, 2019, 08:05:42 am
"Martin_fr
What you want me to do is :

Menu > View > IDE Internals > Show CodeTool Node Info

when I do the above  I get the flowing, There is no Show CodeTool Node Info?
Are we on different versions of the IDE?


 
Menu > View > IDE Internals > About FPC
                                              About IDE
                                              What Needs Building
                                              Debug Options


Title: Re: Bug I think.
Post by: six1 on December 06, 2019, 08:43:13 am
LAZ v2.0.6, i can see it...

Title: Re: Bug I think.
Post by: JLWest on December 06, 2019, 09:45:35 am
Here is what I get?
Title: Re: Bug I think.
Post by: mattias on December 06, 2019, 09:48:04 am
The "Show codetools node info" comes from package "cody".
TinyPortal © 2005-2018