Recent

Author Topic: Bug I think.  (Read 2615 times)

JLWest

  • Hero Member
  • *****
  • Posts: 612
Bug I think.
« 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.



FPC 3.2.0, Lazarus IDE v2.0.4
 Windows 10 Pro 32-GB
 Intel i7 770K CPU 4.2GHz 32702MB Ram
GeForce GTX 1080 Graphics - 8 Gig
4.1 TB

winni

  • Hero Member
  • *****
  • Posts: 590
Re: Bug I think.
« Reply #1 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

JLWest

  • Hero Member
  • *****
  • Posts: 612
Re: Bug I think.
« Reply #2 on: December 01, 2019, 09:09:33 am »
It's that "courageous SAVE" that get's your attention.

Thanks' I'll try it. (Maybe)
FPC 3.2.0, Lazarus IDE v2.0.4
 Windows 10 Pro 32-GB
 Intel i7 770K CPU 4.2GHz 32702MB Ram
GeForce GTX 1080 Graphics - 8 Gig
4.1 TB

PaulRowntree

  • Jr. Member
  • **
  • Posts: 73
    • Paul Rowntree
Re: Bug I think.
« Reply #3 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.
Paul Rowntree
- coding for instrument control, data acquisition & analysis, CNC systems

Martin_fr

  • Administrator
  • Hero Member
  • *
  • Posts: 5788
    • wiki
Re: Bug I think.
« Reply #4 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

JLWest

  • Hero Member
  • *****
  • Posts: 612
Re: Bug I think.
« Reply #5 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.
 
FPC 3.2.0, Lazarus IDE v2.0.4
 Windows 10 Pro 32-GB
 Intel i7 770K CPU 4.2GHz 32702MB Ram
GeForce GTX 1080 Graphics - 8 Gig
4.1 TB

jamie

  • Hero Member
  • *****
  • Posts: 2162
Re: Bug I think.
« Reply #6 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.
Number 1 at blue screen app creations!

winni

  • Hero Member
  • *****
  • Posts: 590
Re: Bug I think.
« Reply #7 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

Martin_fr

  • Administrator
  • Hero Member
  • *
  • Posts: 5788
    • wiki
Re: Bug I think.
« Reply #8 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.

Martin_fr

  • Administrator
  • Hero Member
  • *
  • Posts: 5788
    • wiki
Re: Bug I think.
« Reply #9 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.


six1

  • Jr. Member
  • **
  • Posts: 76
Re: Bug I think.
« Reply #10 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
« Last Edit: December 05, 2019, 07:50:05 am by six1 »

marcov

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 7613
Re: Bug I think.
« Reply #11 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.

Martin_fr

  • Administrator
  • Hero Member
  • *
  • Posts: 5788
    • wiki
Re: Bug I think.
« Reply #12 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.


JLWest

  • Hero Member
  • *****
  • Posts: 612
Re: Bug I think.
« Reply #13 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.

     
FPC 3.2.0, Lazarus IDE v2.0.4
 Windows 10 Pro 32-GB
 Intel i7 770K CPU 4.2GHz 32702MB Ram
GeForce GTX 1080 Graphics - 8 Gig
4.1 TB

Martin_fr

  • Administrator
  • Hero Member
  • *
  • Posts: 5788
    • wiki
Re: Bug I think.
« Reply #14 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.