Recent

Author Topic: [SOLVED] ghost ppcx64.exe process in lazarus trunk  (Read 1652 times)

cpicanco

  • Hero Member
  • *****
  • Posts: 660
  • Behavioral Scientist and Programmer
    • Portfolio
[SOLVED] ghost ppcx64.exe process in lazarus trunk
« on: October 27, 2024, 05:56:58 pm »
Hi everyone, I was testing the trunk version of fpc and lazarus yesterday and I found (today) that my cpu was being drowned by ppcx64.exe, even if I click to stop (Ctrl+F2). So I need to use the task manager to kill these ghost process. Can anyone confirm this? Should I report it as a bug?

EDIT:
Today I updated fpc and lazarus and now the bug is gone
Lazarus 4.99 (rev main_4_99-1018-g3664d7bb93) FPC 3.3.1 x86_64-win64-win32/win64
« Last Edit: January 26, 2025, 11:08:14 pm by cpicanco »
Be mindful and excellent with each other.
https://github.com/cpicanco/

cpicanco

  • Hero Member
  • *****
  • Posts: 660
  • Behavioral Scientist and Programmer
    • Portfolio
Re: ghost ppcx64.exe process in lazarus trunk
« Reply #1 on: October 27, 2024, 07:30:33 pm »
I guess it is getting stuck somewhere with no output message, maybe an infinite loop??
Be mindful and excellent with each other.
https://github.com/cpicanco/

Thaddy

  • Hero Member
  • *****
  • Posts: 16540
  • Kallstadt seems a good place to evict Trump to.
Re: ghost ppcx64.exe process in lazarus trunk
« Reply #2 on: October 27, 2024, 07:52:44 pm »
If it is during the cpmpilation iof lazarus/fpc tself try to set the number of cores used to one. (maybe two)
I ran into the same issue or similar and it was just blocking threads/thread contention/stalls.
Probable cause is that, say, given 4 cores  compilation takes four cores, while it should take a max of three.
Also core affinity and priority are not properly set. (claiming "world domination"!)
So it maxes out the system in some cases and the system does not like it, especially if there are other processes running take take multiple cores. (like a browser) The multi-threaded /spawned process compiling is not very well designed.

If it is your own code that causes this: show it.
« Last Edit: October 27, 2024, 08:00:46 pm by Thaddy »
But I am sure they don't want the Trumps back...

cpicanco

  • Hero Member
  • *****
  • Posts: 660
  • Behavioral Scientist and Programmer
    • Portfolio
Re: ghost ppcx64.exe process in lazarus trunk
« Reply #3 on: October 27, 2024, 08:01:13 pm »
Yes, it is during compilation, ppcx64.exe is getting stuck somehow. How to set the number of cores to test your suggestion?
Be mindful and excellent with each other.
https://github.com/cpicanco/

Martin_fr

  • Administrator
  • Hero Member
  • *
  • Posts: 10820
  • Debugger - SynEdit - and more
    • wiki
Re: ghost ppcx64.exe process in lazarus trunk
« Reply #4 on: October 27, 2024, 08:03:27 pm »
In principal it is a bug. However without more info, reporting it wont help much.

Interestingly you said it is still eating CPU. Now if the IDE just started it, and somehow forgot to collect the result, then I would not expect that => I would think it should hang on writing to a handle that has a full queue. That be a forever-wait, but not a CPU burner. 
But I could be wrong on this.

It seems to me more likely that the process had an internal error and entered an endless loop.

Like
https://gitlab.com/freepascal.org/fpc/source/-/issues/39689
https://gitlab.com/freepascal.org/fpc/source/-/issues/39486
(Not sure if they go forever or very long....)

An important step is to watch out when it happens -> and then: Can it be reproduced with whatever you were just compiling?  You may have to recompile clean, or to remove the correct set of ppu files (which may not be easy to find).

Mind that also because it is trunk, it may be a new error. So if you can't reproduce it at will, but get it frequent enough to tell when it is gone, you may downgrade a few 100 revisions, and test that.
Or you may change how you did build your compiler => e.g. maybe the compiler only fails if it itself was build with certain optimizations.


Martin_fr

  • Administrator
  • Hero Member
  • *
  • Posts: 10820
  • Debugger - SynEdit - and more
    • wiki
Re: ghost ppcx64.exe process in lazarus trunk
« Reply #5 on: October 27, 2024, 08:07:30 pm »
The threads are controlled by Lazarus (and only if you build something that needs multiple package being recompiled).

Each fpc instance runs afaik single threaded. So if your Lazarus was closed and not in the tasklist, and that fpc was running (and even for that long), then I would not call that a prime suspect.

Tools > Options >  Message Window

cpicanco

  • Hero Member
  • *****
  • Posts: 660
  • Behavioral Scientist and Programmer
    • Portfolio
Re: ghost ppcx64.exe process in lazarus trunk
« Reply #6 on: October 27, 2024, 08:08:22 pm »
Yes! I just found a thread where JuhaManninen says code will always compile in a single thread: https://forum.lazarus.freepascal.org/index.php?topic=37793.0
Be mindful and excellent with each other.
https://github.com/cpicanco/

Martin_fr

  • Administrator
  • Hero Member
  • *
  • Posts: 10820
  • Debugger - SynEdit - and more
    • wiki
Re: ghost ppcx64.exe process in lazarus trunk
« Reply #7 on: October 27, 2024, 08:22:45 pm »
Yes! I just found a thread where JuhaManninen says code will always compile in a single thread: https://forum.lazarus.freepascal.org/index.php?topic=37793.0

the IDE's code compiles in a single thread.

"the IDE code" => that is the "project IDE", so not packages.

- When you call fpc then that task will run a single thread.
- When you call fpc with your project.lpr then that fpc process, in its single thread will compile each of the units you use.
- However units from the RTL and packages are at that time already compiled, they exist as ppu files

But when your project
- has several packages
- they have changed, or otherwise need to be compiled each
- they do not depend on each other
- then you can call fpc twice. 
That is like when you compile to independent projects, you can call 2 times the fpc exe and have both processes run next to each other.

Each fpc still only have on thread. So the really you run several processes not threads.

The Lazarus IDE will internally run threads to run fpc (even if you only run one instance of fpc). I am not sure if the IDE will need one thread per fpc or less....

Anyway, if Lazarus is not running, then there are no concurrent threads.

cpicanco

  • Hero Member
  • *****
  • Posts: 660
  • Behavioral Scientist and Programmer
    • Portfolio
Re: ghost ppcx64.exe process in lazarus trunk
« Reply #8 on: October 27, 2024, 08:53:16 pm »
I am using fpcupdeluxe to install. Before clicking at the big "install" button, I checked both "Debug" checkboxes in "Override Setup" and checked "Include help" inside "Misc. settings".

The revision I am running is Lazarus 4.99 (rev main_4_99-416-gc3c7999e20), FPC 3.3.1 x86_64-win64-win32/win64.

I cannot reproduce it with a simple new project.

I think I know exactly when it happens when trying to compile the project I am working on (this one here https://gitlab.com/freepascal.org/fpc/source/-/issues/40487).

1) Make sure to build the software using "clean up and build"
2) Close the software using CTRL+F2 or clicking at the corresponding button.
3) Edit any file from the project, for example, adding a new line
4) Hit "F9". It will get stuck after some seconds without verbose and will stuck after some minutes with show everything option.
5) Press CTRL+F2, kill ppcx64.exe using the task manager
6) Hit "F9" again, then it will compile successfully.
7) Close the program normally or press CTRL+F2.
8) Repeat from step 3 to reproduce again.
Be mindful and excellent with each other.
https://github.com/cpicanco/

cpicanco

  • Hero Member
  • *****
  • Posts: 660
  • Behavioral Scientist and Programmer
    • Portfolio
Re: ghost ppcx64.exe process in lazarus trunk
« Reply #9 on: October 27, 2024, 08:59:28 pm »
Now I will try that:

Quote
Mind that also because it is trunk, it may be a new error. So if you can't reproduce it at will, but get it frequent enough to tell when it is gone, you may downgrade a few 100 revisions, and test that.
Be mindful and excellent with each other.
https://github.com/cpicanco/

jamie

  • Hero Member
  • *****
  • Posts: 6801
Re: ghost ppcx64.exe process in lazarus trunk
« Reply #10 on: October 27, 2024, 09:08:26 pm »
This looks like the same type of error I was getting recently, a project with many small units. Make a change in one of the units that maybe relied on by a few others and the compiler gets very busy doing a compile and then fails with an internal error giving no location.

 But that was broken down a little more in detail by someone else where they added debug info to the compiler and tried it again.

 It seems due to the use of Generics.

 I was using the Generics.Collections unit and stopped using it, it seems a little heavy and whatever else it maybe, I only use the FPG generics and my own and I haven't yet seen that error, but then again, I haven't been working that hard on it lately. :-[
The only true wisdom is knowing you know nothing

cpicanco

  • Hero Member
  • *****
  • Posts: 660
  • Behavioral Scientist and Programmer
    • Portfolio
Re: ghost ppcx64.exe process in lazarus trunk
« Reply #11 on: October 27, 2024, 09:14:21 pm »
Do you know a faster way to compile lazarus with a specific revision than using fpcupdeluxe??
Be mindful and excellent with each other.
https://github.com/cpicanco/

cpicanco

  • Hero Member
  • *****
  • Posts: 660
  • Behavioral Scientist and Programmer
    • Portfolio
Re: ghost ppcx64.exe process in lazarus trunk
« Reply #12 on: October 27, 2024, 09:26:38 pm »
I started using "Generics.Collections" because there is a blocking bug in FPG generics for me (https://forum.lazarus.freepascal.org/index.php/topic,65269.msg497252.html#msg497252), that prevented me to use TFPGMap. It is beyond my knowledge finding how to fix it.

The present bug, for sure, is also beyond my knowledge, however I hope I can work around it changing versions.
« Last Edit: October 27, 2024, 09:28:16 pm by cpicanco »
Be mindful and excellent with each other.
https://github.com/cpicanco/

jamie

  • Hero Member
  • *****
  • Posts: 6801
Re: ghost ppcx64.exe process in lazarus trunk
« Reply #13 on: October 27, 2024, 09:33:53 pm »
Strange, I use the TFPGMap and I have not yet seen an issue with it.

 The only problem I see at times is if you are using Records for items, then you need to supply a couple of compare operators in the record so the generics can use that for the compare code.
The only true wisdom is knowing you know nothing

cpicanco

  • Hero Member
  • *****
  • Posts: 660
  • Behavioral Scientist and Programmer
    • Portfolio
Re: ghost ppcx64.exe process in lazarus trunk
« Reply #14 on: October 27, 2024, 10:00:50 pm »
It is really strange, indeed. If you think you can shed some light on this, I would really appreciate it. I really prefer FPG sintax.

(I also used the compare function with no problems at all. Until I found a blocking one with a simple MyMap.add() that was "magically" gone trusting in marcov's intuition and exchanging libraries.)
Be mindful and excellent with each other.
https://github.com/cpicanco/

 

TinyPortal © 2005-2018