Community
Participate
Working Groups
Build Identifier: 20100617-1415 Auto completion hangs up for macros and functions but it works good for local variables. It is easy to reproduce for the following snippet. If you try to execute auto completion in the place marked by !{cursor}! Eclipse will hang up. I tried it out with the latest release of CDT and even with CDT compiled from sources. This bug is reproduced on several machine and on different platforms (Windows XP, Windows 7). #include <stdio.h> #include "macros.h" DBG_TAG_MODULE(MAIN) DBG_TAG_!{cursor}!SUBMODULE(main) int main() { return 0; } Content of my eclipse.ini -startup plugins/org.eclipse.equinox.launcher_1.1.0.v20100507.jar --launcher.library plugins/org.eclipse.equinox.launcher.win32.win32.x86_1.1.0.v20100503 -product org.eclipse.epp.package.rcp.product --launcher.defaultAction openFile --launcher.XXMaxPermSize 256M -showsplash org.eclipse.platform --launcher.XXMaxPermSize 256m --launcher.defaultAction openFile -vmargs -Dosgi.requiredJavaVersion=1.5 -Xms40m -Xmx256m Reproducible: Always
The parser seems to get into an endless loop in countKnRCParms: Thread [main] (Suspended) GNUCSourceParser.countKnRCParms() line: 1894 GNUCSourceParser.functionDeclarator(DeclarationOptions) line: 1490 GNUCSourceParser.declarator(List<IASTPointerOperator>, IASTName, IASTDeclarator, int, int, DeclarationOptions) line: 1408 GNUCSourceParser.declarator(IASTDeclSpecifier, DeclarationOptions) line: 1343 GNUCSourceParser.initDeclarator(IASTDeclSpecifier, DeclarationOptions) line: 1302 GNUCSourceParser(AbstractGNUSourceCodeParser).declSpecifierSequence_initDeclarator(DeclarationOptions, boolean) line: 1608 GNUCSourceParser.simpleDeclaration(DeclarationOptions) line: 309 GNUCSourceParser.declaration(DeclarationOptions) line: 292 GNUCSourceParser(AbstractGNUSourceCodeParser).declarationList(IASTDeclarationListOwner, DeclarationOptions, boolean, int) line: 1315 GNUCSourceParser(AbstractGNUSourceCodeParser).parseTranslationUnit() line: 1253 GNUCSourceParser(AbstractGNUSourceCodeParser).translationUnit() line: 1248 GNUCSourceParser(AbstractGNUSourceCodeParser).parse() line: 645 GCCLanguage(AbstractCLikeLanguage).getCompletionNode(FileContent, IScannerInfo, IncludeFileContentProvider, IIndex, IParserLogService, int) line: 171 WorkingCopy(TranslationUnit).getCompletionNode(IIndex, int, int) line: 897 CContentAssistInvocationContext.getCompletionNode() line: 159 DOMCompletionProposalComputer(ParsingBasedProposalComputer).computeCompletionProposals(ContentAssistInvocationContext, IProgressMonitor) line: 47 CompletionProposalComputerDescriptor.computeCompletionProposals(ContentAssistInvocationContext, IProgressMonitor) line: 300 CompletionProposalCategory.computeCompletionProposals(ContentAssistInvocationContext, String, SubProgressMonitor) line: 261 CContentAssistProcessor(ContentAssistProcessor).collectProposals(ITextViewer, int, IProgressMonitor, ContentAssistInvocationContext) line: 267 CContentAssistProcessor(ContentAssistProcessor).computeCompletionProposals(ITextViewer, int) line: 220 ContentAssistant.computeCompletionProposals(ITextViewer, int) line: 1834 CompletionProposalPopup.computeProposals(int) line: 556 CompletionProposalPopup.access$16(CompletionProposalPopup, int) line: 553 CompletionProposalPopup$14.run() line: 1542 BusyIndicator.showWhile(Display, Runnable) line: 70 CompletionProposalPopup.incrementalComplete() line: 1536 ContentAssistant.showPossibleCompletions() line: 1659 CEditor$AdaptedSourceViewer.doOperation(int) line: 328 ContentAssistAction$1.run() line: 82 BusyIndicator.showWhile(Display, Runnable) line: 70 ContentAssistAction.run() line: 80 ContentAssistAction(Action).runWithEvent(Event) line: 498 ActionHandler.execute(Map) line: 185 LegacyHandlerWrapper.execute(ExecutionEvent) line: 109 Command.executeWithChecks(ExecutionEvent) line: 476 ParameterizedCommand.executeWithChecks(Object, Object) line: 508 HandlerService.executeCommand(ParameterizedCommand, Event) line: 169 WorkbenchKeyboard.executeCommand(Binding, Event) line: 468 WorkbenchKeyboard.press(List, Event) line: 786 WorkbenchKeyboard.processKeyEvent(List, Event) line: 885 WorkbenchKeyboard.filterKeySequenceBindings(Event) line: 567 WorkbenchKeyboard.access$3(WorkbenchKeyboard, Event) line: 508 WorkbenchKeyboard$KeyDownFilter.handleEvent(Event) line: 123 EventTable.sendEvent(Event) line: 84 Display.filterEvent(Event) line: 1253 StyledText(Widget).sendEvent(Event) line: 1052 StyledText(Widget).sendEvent(int, Event, boolean) line: 1077 StyledText(Widget).sendEvent(int, Event) line: 1062 StyledText(Widget).sendKeyEvent(int, int, int, int, Event) line: 1103 StyledText(Widget).sendKeyEvent(int, int, int, int) line: 1099 StyledText(Widget).wmChar(int, int, int) line: 1508 StyledText(Control).WM_CHAR(int, int) line: 4268 StyledText(Canvas).WM_CHAR(int, int) line: 345 StyledText(Control).windowProc(int, int, int, int) line: 4160 StyledText(Canvas).windowProc(int, int, int, int) line: 341 Display.windowProc(int, int, int, int) line: 4873 OS.DispatchMessageW(MSG) line: not available [native method] OS.DispatchMessage(MSG) line: 2459 Display.readAndDispatch() line: 3655 Workbench.runEventLoop(Window$IExceptionHandler, Display) line: 2629 Workbench.runUI() line: 2593 Workbench.access$4(Workbench) line: 2427 Workbench$7.run() line: 670 Realm.runWithDefault(Realm, Runnable) line: 332 Workbench.createAndRunWorkbench(Display, WorkbenchAdvisor) line: 663 PlatformUI.createAndRunWorkbench(Display, WorkbenchAdvisor) line: 149 IDEApplication.start(IApplicationContext) line: 115 EclipseAppHandle.run(Object) line: 196 EclipseAppLauncher.runApplication(Object) line: 110 EclipseAppLauncher.start(Object) line: 79 EclipseStarter.run(Object) line: 369 EclipseStarter.run(String[], Runnable) line: 179 NativeMethodAccessorImpl.invoke0(Method, Object, Object[]) line: not available [native method] NativeMethodAccessorImpl.invoke(Object, Object[]) line: 39 DelegatingMethodAccessorImpl.invoke(Object, Object[]) line: 25 Method.invoke(Object, Object...) line: 597 Main.invokeFramework(String[], URL[]) line: 619 Main.basicRun(String[]) line: 574 Main.run(String[]) line: 1407 Main.main(String[]) line: 1383
Created attachment 178242 [details] testcase + fix Note, that there is something going wrong with the expansion of the macro. I guess that either the include file is not resolved or that the macro-definition is hidden in an inactive code branch. You probably have to adjust the configuration (include search path, defined symbols) of the indexer. Without the macro expansion the construct is interpreted as the beginning of a K&R-style function definition. With that the parser runs into an infinite loop. The provided patch fixes that.
*** cdt cvs genie on behalf of mschorn *** Bug 324384: Content assist within K&R style function definition. [*] BasicCompletionTest.java 1.22.2.2 http://dev.eclipse.org/viewcvs/index.cgi/org.eclipse.cdt-core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/prefix/BasicCompletionTest.java?root=Tools_Project&r1=1.22.2.1&r2=1.22.2.2 [*] GNUCSourceParser.java 1.151.2.1 http://dev.eclipse.org/viewcvs/index.cgi/org.eclipse.cdt-core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/c/GNUCSourceParser.java?root=Tools_Project&r1=1.151&r2=1.151.2.1
I've applied the attached patch but there is the exception when executing code completion for the following code (as usual !{cursor}! is the cursor position): DBG_TAG_MODULE(AcMy) int __AcMy_Init(P!{cursor}!AcMy self); Exception stack: eclipse.buildId=I20100608-0911 java.version=1.6.0_21 java.vendor=Sun Microsystems Inc. BootLoader constants: OS=win32, ARCH=x86, WS=win32, NL=uk_UA Framework arguments: -product org.eclipse.platform.ide Command-line arguments: -product org.eclipse.platform.ide -data D:\Projects\Eclipse_plugins_helios/../runtime-EclipseApplication -dev file:D:/Projects/Eclipse_plugins_helios/.metadata/.plugins/org.eclipse.pde.core/Eclipse Application/dev.properties -os win32 -ws win32 -arch x86 -consoleLog Error Mon Sep 06 16:47:38 EEST 2010 Unhandled event loop exception java.lang.OutOfMemoryError: Java heap space at org.eclipse.cdt.internal.core.parser.scanner.CPreprocessor.nextToken(CPreprocessor.java:580) at org.eclipse.cdt.internal.core.dom.parser.AbstractGNUSourceCodeParser.fetchToken(AbstractGNUSourceCodeParser.java:260) at org.eclipse.cdt.internal.core.dom.parser.AbstractGNUSourceCodeParser.nextToken(AbstractGNUSourceCodeParser.java:284) at org.eclipse.cdt.internal.core.dom.parser.AbstractGNUSourceCodeParser.lookaheadToken(AbstractGNUSourceCodeParser.java:294) at org.eclipse.cdt.internal.core.dom.parser.AbstractGNUSourceCodeParser.LA(AbstractGNUSourceCodeParser.java:317) at org.eclipse.cdt.internal.core.dom.parser.AbstractGNUSourceCodeParser.LT(AbstractGNUSourceCodeParser.java:444) at org.eclipse.cdt.internal.core.dom.parser.c.GNUCSourceParser.createKnRCProblemDeclaration(GNUCSourceParser.java:1937) at org.eclipse.cdt.internal.core.dom.parser.c.GNUCSourceParser.functionDeclarator(GNUCSourceParser.java:1535) at org.eclipse.cdt.internal.core.dom.parser.c.GNUCSourceParser.declarator(GNUCSourceParser.java:1413) at org.eclipse.cdt.internal.core.dom.parser.c.GNUCSourceParser.declarator(GNUCSourceParser.java:1348) at org.eclipse.cdt.internal.core.dom.parser.c.GNUCSourceParser.initDeclarator(GNUCSourceParser.java:1307) at org.eclipse.cdt.internal.core.dom.parser.AbstractGNUSourceCodeParser.declSpecifierSequence_initDeclarator(AbstractGNUSourceCodeParser.java:1616) at org.eclipse.cdt.internal.core.dom.parser.c.GNUCSourceParser.simpleDeclaration(GNUCSourceParser.java:309) at org.eclipse.cdt.internal.core.dom.parser.c.GNUCSourceParser.declaration(GNUCSourceParser.java:292) at org.eclipse.cdt.internal.core.dom.parser.AbstractGNUSourceCodeParser.declarationList(AbstractGNUSourceCodeParser.java:1323) at org.eclipse.cdt.internal.core.dom.parser.AbstractGNUSourceCodeParser.parseTranslationUnit(AbstractGNUSourceCodeParser.java:1261) at org.eclipse.cdt.internal.core.dom.parser.AbstractGNUSourceCodeParser.translationUnit(AbstractGNUSourceCodeParser.java:1256) at org.eclipse.cdt.internal.core.dom.parser.AbstractGNUSourceCodeParser.parse(AbstractGNUSourceCodeParser.java:645) at org.eclipse.cdt.core.dom.parser.AbstractCLikeLanguage.getCompletionNode(AbstractCLikeLanguage.java:171) at org.eclipse.cdt.internal.core.model.TranslationUnit.getCompletionNode(TranslationUnit.java:888) at org.eclipse.cdt.internal.ui.text.contentassist.CContentAssistInvocationContext.getCompletionNode(CContentAssistInvocationContext.java:159) at org.eclipse.cdt.internal.ui.text.contentassist.ParsingBasedProposalComputer.computeCompletionProposals(ParsingBasedProposalComputer.java:47) at org.eclipse.cdt.internal.ui.text.contentassist.CompletionProposalComputerDescriptor.computeCompletionProposals(CompletionProposalComputerDescriptor.java:300) at org.eclipse.cdt.internal.ui.text.contentassist.CompletionProposalCategory.computeCompletionProposals(CompletionProposalCategory.java:261) at org.eclipse.cdt.internal.ui.text.contentassist.ContentAssistProcessor.collectProposals(ContentAssistProcessor.java:267) at org.eclipse.cdt.internal.ui.text.contentassist.ContentAssistProcessor.computeCompletionProposals(ContentAssistProcessor.java:220) at org.eclipse.jface.text.contentassist.ContentAssistant.computeCompletionProposals(ContentAssistant.java:1834) at org.eclipse.jface.text.contentassist.CompletionProposalPopup.computeProposals(CompletionProposalPopup.java:556) at org.eclipse.jface.text.contentassist.CompletionProposalPopup.access$16(CompletionProposalPopup.java:553) at org.eclipse.jface.text.contentassist.CompletionProposalPopup$14.run(CompletionProposalPopup.java:1542) at org.eclipse.swt.custom.BusyIndicator.showWhile(BusyIndicator.java:70) at org.eclipse.jface.text.contentassist.CompletionProposalPopup.incrementalComplete(CompletionProposalPopup.java:1536)
Created attachment 178267 [details] fix + testcase Thanks, this patch adresses the second issue.
Fixed in 7.0.1 and 8.0 > 20100906.
*** cdt cvs genie on behalf of mschorn *** Bug 324384: Content assist within K&R style function definition. [*] BasicCompletionTest.java 1.24 http://dev.eclipse.org/viewcvs/index.cgi/org.eclipse.cdt-core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/prefix/BasicCompletionTest.java?root=Tools_Project&r1=1.23&r2=1.24 [*] GNUCSourceParser.java 1.153 http://dev.eclipse.org/viewcvs/index.cgi/org.eclipse.cdt-core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/c/GNUCSourceParser.java?root=Tools_Project&r1=1.152&r2=1.153
*** cdt cvs genie on behalf of mschorn *** Bug 324384: Content assist in invalid K&R parameter decl. [*] BasicCompletionTest.java 1.22.2.3 http://dev.eclipse.org/viewcvs/index.cgi/org.eclipse.cdt-core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/prefix/BasicCompletionTest.java?root=Tools_Project&r1=1.22.2.2&r2=1.22.2.3 [*] GNUCSourceParser.java 1.151.2.2 http://dev.eclipse.org/viewcvs/index.cgi/org.eclipse.cdt-core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/c/GNUCSourceParser.java?root=Tools_Project&r1=1.151.2.1&r2=1.151.2.2 [*] BasicCompletionTest.java 1.25 http://dev.eclipse.org/viewcvs/index.cgi/org.eclipse.cdt-core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/prefix/BasicCompletionTest.java?root=Tools_Project&r1=1.24&r2=1.25 [*] GNUCSourceParser.java 1.154 http://dev.eclipse.org/viewcvs/index.cgi/org.eclipse.cdt-core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/c/GNUCSourceParser.java?root=Tools_Project&r1=1.153&r2=1.154
(In reply to comment #5) > Created an attachment (id=178267) [details] > fix + testcase > Thanks, this patch adresses the second issue. Hi, Markus: For the test case testIncompleteKnrFunction_Bug324384b, the LR parser returns a proposal of CImplicitTypedef with a name "__builtin_va_list", so that it is failed. The parser return a completion node with an empty ASTName, which is bound to org.eclipse.cdt.internal.core.dom.parser.c.CImplicitTypedef later, so proposal is returned as CImplicitTypedef. I am wondering if it is correct too?
(In reply to comment #9) > (In reply to comment #5) > > Created an attachment (id=178267) [details] [details] > > fix + testcase > > Thanks, this patch adresses the second issue. > Hi, Markus: > For the test case testIncompleteKnrFunction_Bug324384b, the LR parser returns a > proposal of CImplicitTypedef with a name "__builtin_va_list", so that it is > failed. > The parser return a completion node with an empty ASTName, which is bound to > org.eclipse.cdt.internal.core.dom.parser.c.CImplicitTypedef later, so proposal > is returned as CImplicitTypedef. > I am wondering if it is correct too? Because the example contains invalid syntax, that's certainly ok. I'll slightly change the test-case such that it passes for the LR-parser, also.
(In reply to comment #10) > ... > Because the example contains invalid syntax, that's certainly ok. I'll > slightly change the test-case such that it passes for the LR-parser, also. I have adjusted the testcase such that there is a prefix for the completion. With that the proposal __builtin.. is wrong. Nevertheless with the LR parser it is computed. I assume that the LR parser erroneously returns a completion name without the prefix.
*** cdt cvs genie on behalf of mschorn *** Bug 324384: Adjusted testcase. [*] BasicCompletionTest.java 1.22.2.4 http://dev.eclipse.org/viewcvs/index.cgi/org.eclipse.cdt-core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/prefix/BasicCompletionTest.java?root=Tools_Project&r1=1.22.2.3&r2=1.22.2.4 [*] BasicCompletionTest.java 1.26 http://dev.eclipse.org/viewcvs/index.cgi/org.eclipse.cdt-core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/prefix/BasicCompletionTest.java?root=Tools_Project&r1=1.25&r2=1.26
I've applied the second patch two and noticed more bugs. I created a source file with only one line: #include "my.h" Bug I: Auto-completion writes additional symbols '__' before show proposals. #include !{cursor}!"my.h" ==> #include __!{proposals list}!"my.h" Bug II: Auto-completion writes characters 'de' and doesn't show proposals #inclu!{cursor}!de "my.h" ==> #include !{cursor}!de "my.h"
(In reply to comment #11) > (In reply to comment #10) > > ... > > Because the example contains invalid syntax, that's certainly ok. I'll > > slightly change the test-case such that it passes for the LR-parser, also. > I have adjusted the testcase such that there is a prefix for the completion. > With that the proposal __builtin.. is wrong. Nevertheless with the LR parser it > is computed. I assume that the LR parser erroneously returns a completion name > without the prefix. Thanks, Markus. The updated test case is passed by LR parser in my workspace testing.
(In reply to comment #13) > I've applied the second patch two and noticed more bugs. I created a source > file with only one line: > #include "my.h" > Bug I: Auto-completion writes additional symbols '__' before show proposals. > #include !{cursor}!"my.h" ==> #include __!{proposals list}!"my.h" > Bug II: Auto-completion writes characters 'de' and doesn't show proposals > #inclu!{cursor}!de "my.h" ==> #include !{cursor}!de "my.h" These issues are unreated, please create a separate bug report for that.
(In reply to comment #15) > (In reply to comment #13) > These issues are unreated, please create a separate bug report for that. OK. I've created bug 324754.