eclipse-cdt / cdt

Eclipse CDT™ C/C++ Development Tools
http://eclipse.org/cdt
Eclipse Public License 2.0
299 stars 198 forks source link

Eclipse CDT is getting stuck Indexing the code #892

Open ks1322 opened 3 weeks ago

ks1322 commented 3 weeks ago

Describe the bug Eclipse CDT is getting stuck Indexing the code

To Reproduce Steps to reproduce the behavior:

  1. Try to index the following code

    int f()
    {
    int x = 0;
    
    return
      x < A<0>::B ?
         x < A<0>::B ?
            x < A<0>::B ?
               x < A<0>::B ? 1 : 0 :
               x < A<0>::B ? 1 : 0 :
            x < A<0>::B ?
               x < A<0>::B ? 1 : 0 :
               x < A<0>::B ? 1 : 0 :
         x < A<0>::B ?
            x < A<0>::B ?
               x < A<0>::B ? 1 : 0 :
               x < A<0>::B ? 1 : 0 :
            x < A<0>::B ?
               x < A<0>::B ?
                  x < A<0>::B ? 1 : 0 :
                  x < A<0>::B ? 1 : 0 :
               x < A<0>::B ?
                  x < A<0>::B ? 1 : 0 :
                  x < A<0>::B ? 1 : 0
    ;
    }
  2. Go to Progress tab
  3. "Indexing: 0/1 sources, 0 headers: Waiting for exclusive access" message appears in Progress tab
  4. Eclipse CDT is getting stuck Indexing the code. Indexing consumes a lot of CPU and never ends.

Expected behavior Indexing process is finished within 1-2 seconds

Version Information (please complete the following information):

dimitarsh1 commented 2 weeks ago

Hi all,

I have a similar issue.

I just download CDT yesterday (different versions; installer and tar.gz) and when I create a managed C++ build it starts indexing and waits for 4-5 minutes (initially I thought it is frozen, so I tried to close it, but after that I let it run and it would finish eventually). But this frozen state happens even if you disable indexing.

It spawns new processes and the CPU utilisation goes up to 100 with little memory being used (the memory is as much as provided in the -Xmx field in the .ini).

I switched from the java which it comes along with to the one I installed (OpenJDK 24) but the same thing happens. The behaviour is reoccuring on my machine (details below) but doesn't happen on another Debian machine with the same kernel.

image

It spawns many processes, as you can see below and waits for them all to finish. image

The behaviour is similar to what is in this post here: http://javamoods.blogspot.com/2009/04/eclipse-user-operation-is-waiting-and.html (and other bug reports but from many years ago).

I attach also the .log from the .metadata folder. [.log](https://github.com/user-attachments/files/16784033/default.log)

System info: $ lsb_release -a No LSB modules are available. Distributor ID: Debian Description: Debian GNU/Linux trixie/sid Release: n/a Codename: trixie

$ uname -r 6.6.15-amd64

$ java --version openjdk 24-ea 2025-03-18 OpenJDK Runtime Environment (build 24-ea+10-Debian-2) OpenJDK 64-Bit Server VM (build 24-ea+10-Debian-2, mixed mode, sharing)

I have used all these eclipse versions with the same biheviour: image

Any idea? Any more info needed from my side?

Thanks in advance.

ks1322 commented 2 weeks ago

@dimitarsh1, what code are you trying to index? In my case I do not disable indexing and it works in general for large codebase. Only mentioned piece of code in https://github.com/eclipse-cdt/cdt/issues/892#issue-2484855081 makes indexing to stuck.

dimitarsh1 commented 2 weeks ago

When I create a new project, when I build a project, when I run a project. Basically it always creates many new processes which cause the main one to halt/wait.

Perhaps my issue is unrelated to yours and I should open a new issue.

Confidentiality Note: The information contained in this message, and any attachments, may contain confidential and/or privileged material. It is intended solely for the person(s) or entity to which it is addressed. Any review, retransmission, dissemination, or taking of any action in reliance upon this information by persons or entities other than the intended recipient(s) is prohibited. If you received this in error, please contact the sender and delete the material from any computer. Please do not send any sensitive data by email attachment as all such emails will be deleted. Electronic mail to, from or within Tilburg University may be the subject of a request under the Freedom of Information Act.

Dr. Dimitar Shterionov, Assistant Professor in Artificial Intelligence, Department of Cognitive Science and Artificial Intelligence, Tilburg University Technical & Scientific coordinator of the SignON project (signon-project.euhttp://signon-project.eu/)


From: ks1322 @.> Sent: Wednesday, August 28, 2024 8:26:41 PM To: eclipse-cdt/cdt @.> Cc: Dimitar Shterionov @.>; Mention @.> Subject: Re: [eclipse-cdt/cdt] Eclipse CDT is getting stuck Indexing the code (Issue #892)

@dimitarsh1https://github.com/dimitarsh1, what code are you trying to index? In my case I do not disable indexing and it works in general for large codebase. Only mentioned piece of code in #892 (comment)https://github.com/eclipse-cdt/cdt/issues/892#issue-2484855081 makes indexing to stuck.

— Reply to this email directly, view it on GitHubhttps://github.com/eclipse-cdt/cdt/issues/892#issuecomment-2315999626, or unsubscribehttps://github.com/notifications/unsubscribe-auth/ADYLMEU3XZWMUWDKONP5PT3ZTYI6DAVCNFSM6AAAAABNB4IR26VHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDGMJVHE4TSNRSGY. You are receiving this because you were mentioned.Message ID: @.***>

jld01 commented 2 weeks ago

Related to Bugzilla 363609.

See the code comments in the TemplateIdStrategy class.

I can avoid the endless loop reported above by disabling this optimization in the source code.

ks1322 commented 6 days ago

I don't think an endless loop is invoked in Eclipse. Looks like some exponential algorithm is invoked. If I remove several instances of conditional operator then no stuck is observed, Indexing process finishes.

gvl2023 commented 5 days ago

I've seen indexer getting stuck with increasing heap usage and an eventual OOM error. I had to exclude folders containing sources that the indexer chokes on. Hope I'm wrong but with the recently introduced language-server based editor the chances of the indexer getting patched are fairly slim.