Bug 579138 - Stack Overflow in Builder
Summary: Stack Overflow in Builder
Status: RESOLVED FIXED
Alias: None
Product: CDT
Classification: Tools
Component: cdt-build (show other bugs)
Version: 10.5.0   Edit
Hardware: PC Linux
: P3 blocker (vote)
Target Milestone: 10.6.0   Edit
Assignee: Jonah Graham CLA
QA Contact: Jonah Graham CLA
URL:
Whiteboard:
Keywords: regression
: 561568 (view as bug list)
Depends on:
Blocks:
 
Reported: 2022-03-07 23:06 EST by Allan Wallace CLA
Modified: 2022-03-08 19:06 EST (History)
4 users (show)

See Also:


Attachments
Stack Trace Of Recursive (248.02 KB, application/gzip)
2022-03-07 23:06 EST, Allan Wallace CLA
no flags Details

Note You need to log in before you can comment on or make changes to this bug.
Description Allan Wallace CLA 2022-03-07 23:06:05 EST
Created attachment 288183 [details]
Stack Trace Of Recursive

Upgraded from Oxygen to 2021-12 and now the build is getting a stackoverflow exception because of an infinite recursive loop.
Initially it looked looked like the loop was 
org.eclipse.core.runtime.ProgressMonitorWrapper.internalWorked(ProgressMonitorWrapper.java:101)
org.eclipse.core.runtime.SubProgressMonitor.internalWorked(SubProgressMonitor.java:180)
org.eclipse.core.runtime.ProgressMonitorWrapper.internalWorked(ProgressMonitorWrapper.java:101)
org.eclipse.core.runtime.SubProgressMonitor.internalWorked(SubProgressMonitor.java:180)

But a longer stack trace which is attached shows an earlier loop of
org.eclipse.cdt.managedbuilder.internal.core.CommonBuilder.build(CommonBuilder.java:496)
org.eclipse.cdt.managedbuilder.internal.core.CommonBuilder.buildReferencedConfigs(CommonBuilder.java:556)
org.eclipse.cdt.managedbuilder.internal.core.CommonBuilder.build(CommonBuilder.java:496)
org.eclipse.cdt.managedbuilder.internal.core.CommonBuilder.buildReferencedConfigs(CommonBuilder.java:556)
org.eclipse.cdt.managedbuilder.internal.core.CommonBuilder.build(CommonBuilder.java:496)
org.eclipse.cdt.managedbuilder.internal.core.CommonBuilder.buildReferencedConfigs(CommonBuilder.java:556)
org.eclipse.cdt.managedbuilder.internal.core.CommonBuilder.build(CommonBuilder.java:496)
org.eclipse.cdt.managedbuilder.internal.core.CommonBuilder.buildReferencedConfigs(CommonBuilder.java:556)
org.eclipse.cdt.managedbuilder.internal.core.CommonBuilder.build(CommonBuilder.java:496)
org.eclipse.cdt.managedbuilder.internal.core.CommonBuilder.buildReferencedConfigs(CommonBuilder.java:556)
org.eclipse.cdt.managedbuilder.internal.core.CommonBuilder.build(CommonBuilder.java:496)
org.eclipse.cdt.managedbuilder.internal.core.CommonBuilder.build(CommonBuilder.java:463)
org.eclipse.core.internal.events.BuildManager$2.run(BuildManager.java:853)
org.eclipse.core.runtime.SafeRunner.run(SafeRunner.java:45)
org.eclipse.core.internal.events.BuildManager.basicBuild(BuildManager.java:232)
Comment 1 Jonah Graham CLA 2022-03-08 10:29:46 EST
So Oxygen is quite a while ago, so not sure what the particular problem may be here. The biggest contenders are a regression from one of Bug 546407 or Bug 571134.

Can you provide additional information? For example Bug 546407 was fixed in CDT 9.9 aka Eclipse 2019-09. If your example fails in that version that would explain it. 

Bug 571134 was fixed in CDT 10.3 aka 2021-06.

----


> But a longer stack trace which is attached shows an earlier loop of
Thanks for this longer analysis. The error is certainly because build is calling buildReferencedConfigs and recursing. Each of those calls makes a new SubProgressMonitor that is chained, so operations such as done need to flow through each item in the chain.

The transition point is:
org.eclipse.core.runtime.SubProgressMonitor.internalWorked(SubProgressMonitor.java:180)
org.eclipse.core.runtime.ProgressMonitorWrapper.internalWorked(ProgressMonitorWrapper.java:101)
org.eclipse.core.runtime.SubProgressMonitor.internalWorked(SubProgressMonitor.java:180)
org.eclipse.core.runtime.ProgressMonitorWrapper.internalWorked(ProgressMonitorWrapper.java:101)
org.eclipse.core.runtime.SubProgressMonitor.done(SubProgressMonitor.java:166)
org.eclipse.cdt.managedbuilder.internal.core.CommonBuilder.buildReferencedConfigs(CommonBuilder.java:568)
org.eclipse.cdt.managedbuilder.internal.core.CommonBuilder.build(CommonBuilder.java:496)
org.eclipse.cdt.managedbuilder.internal.core.CommonBuilder.buildReferencedConfigs(CommonBuilder.java:556)
org.eclipse.cdt.managedbuilder.internal.core.CommonBuilder.build(CommonBuilder.java:496)
org.eclipse.cdt.managedbuilder.internal.core.CommonBuilder.buildReferencedConfigs(CommonBuilder.java:556)
Comment 2 Jonah Graham CLA 2022-03-08 10:41:58 EST
I can reproduce the problem. The code stack overflows when there is a cycle in the referenced projects/configurations.

Please review the references in Project Properties -> C/C++ General -> Path and Symbols -> References tab and let me know if there are any cycles between your projects in your workspace. The cycle may involve multiple configurations - see steps to reproduce for some more insight.

---

Steps to reproduce:
- Make a project
- Project Properties -> C/C++ General -> Path and Symbols -> References 
- With Configuration "Debug" selected (drop down at top of UI), make the reference to "Release"
- Change configuration to "Release" and make that reference "Debug"

The same type of cycle can be done between multiple projects.

---

What to do next:
- We need to detect this cycle at some point.
Comment 3 Jonah Graham CLA 2022-03-08 10:42:32 EST
*** Bug 561568 has been marked as a duplicate of this bug. ***
Comment 4 Jonah Graham CLA 2022-03-08 10:44:12 EST
@Umair - the code from Bug 546407 has caused this regression. Are you able to have a look at this?
Comment 5 Jonah Graham CLA 2022-03-08 10:45:09 EST
Turns out some work was started on this already - https://git.eclipse.org/r/c/cdt/org.eclipse.cdt/+/160115/ - lets see if we can complete it now.
Comment 6 Jonah Graham CLA 2022-03-08 11:10:00 EST
We are in the last couple of days for CDT 10.6.0 - I have sent out a request for a review on this to see if it is suitable to put in at the last moment - https://www.eclipse.org/lists/cdt-dev/msg35134.html
Comment 7 Allan Wallace CLA 2022-03-08 17:52:15 EST
I can confirm this is the bug I am seeing. I tracked down two projects referencing each other. I took the uneccessary reference out and the build worked.
Thanks for the feedback.
Comment 9 Jonah Graham CLA 2022-03-08 19:06:44 EST
(In reply to Allan Wallace from comment #7)
> I can confirm this is the bug I am seeing. I tracked down two projects
> referencing each other. I took the uneccessary reference out and the build
> worked.
> Thanks for the feedback.

Thank you Allan for taking the time to file the bug and confirming that your immediate issue is worked around. The CDT 10.6.0 version of CDT that is out in the next few days won't have the stackoverflow, but it is certainly better to not have the cycle in your projects.