Bug 561638 - Invoking 'Add semicolon' quickfix causes Eclipse to freeze
Summary: Invoking 'Add semicolon' quickfix causes Eclipse to freeze
Status: NEW
Alias: None
Product: CDT
Classification: Tools
Component: cdt-editor (show other bugs)
Version: 9.11.0   Edit
Hardware: PC Linux
: P3 normal (vote)
Target Milestone: ---   Edit
Assignee: Project Inbox CLA
QA Contact: Jonah Graham CLA
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2020-04-01 05:48 EDT by Martin Coufal CLA
Modified: 2020-04-01 11:42 EDT (History)
5 users (show)

See Also:


Attachments
screenshot (299.42 KB, image/png)
2020-04-01 11:11 EDT, Martin Coufal CLA
no flags Details
stack trace (16.75 KB, text/plain)
2020-04-01 11:42 EDT, Martin Coufal CLA
no flags Details

Note You need to log in before you can comment on or make changes to this bug.
Description Martin Coufal CLA 2020-04-01 05:48:40 EDT
Invoking a quickfix on a code (with a misplaced semicolon) below causes Eclipse to freeze:
'''
#include <stdio.h>
#include <stdlib.h>

typedef enum {
   MY_ENUM_VAL0 = 0,/**< MY_ENUM_VAL0 */
   MY_ENUM_VAL1 = 1 /**< MY_ENUM_VAL1 */
}; MY_ENUM_T /** invoke quickfix -> eclipse freezes*/

int main(void) {
	puts("!!!Hello World!!!");
	return EXIT_SUCCESS;
}
'''

Steps to reproduce:
1) run Eclipse
2) create new Hello World ANSI C project
3) replace auto-created source with code above and save
4) build the project
5) set focus to line with comment: /** invoke quickfix -> eclipse freezes*/
6) press ctrl+1, select 'Add semicolon' quickfix
Eclipse freezes, no error in workspace log appears.


My configuration:
Eclipse platform 4.15 (I20200305-0155)
Eclipse CDT 9.11.0.202003091030
Comment 1 Marco Stornelli CLA 2020-04-01 10:18:52 EDT
I can't reproduce this problem because the output from GCC is 

make all 
Building file: ../main.c
Invoking: GCC C Compiler
gcc -O0 -g3 -pedantic -Wall -Wextra -c -fmessage-length=0 -MMD -MP -MF"main.d" -MT"main.o" -o "main.o" "../main.c"
../main.c:15:1: warning: useless storage class specifier in empty declaration
 }; MY_ENUM_T /** invoke quickfix -> eclipse freezes*/
 ^
../main.c:17:1: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘int’
 int main(void) {
 ^~~
make: *** [subdir.mk:20: main.o] Error 1
"make all" terminated with exit code 2. Build might be incomplete.

So quickfix is not shown at all for me.

It could help if you can get a stack trace.
Comment 2 Martin Coufal CLA 2020-04-01 11:10:30 EDT
(In reply to Marco Stornelli from comment #1)
> I can't reproduce this problem because the output from GCC is 
> 
> make all 
> Building file: ../main.c
> Invoking: GCC C Compiler
> gcc -O0 -g3 -pedantic -Wall -Wextra -c -fmessage-length=0 -MMD -MP
> -MF"main.d" -MT"main.o" -o "main.o" "../main.c"
> ../main.c:15:1: warning: useless storage class specifier in empty declaration
>  }; MY_ENUM_T /** invoke quickfix -> eclipse freezes*/
>  ^
> ../main.c:17:1: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’
> before ‘int’
>  int main(void) {
>  ^~~
> make: *** [subdir.mk:20: main.o] Error 1
> "make all" terminated with exit code 2. Build might be incomplete.
> 
> So quickfix is not shown at all for me.

My build fails as well (which is expected, since there is syntax error), but after the build fails, I can see the line highlighted and quickfix available (attaching screenshot).

My gcc (9.2.1 20190827) says more or less the same:
'''
make all 
Building file: ../src/testC.c
Invoking: GCC C Compiler
gcc -O0 -g3 -Wall -c -fmessage-length=0 -MMD -MP -MF"src/testC.d" -MT"src/testC.o" -o "src/testC.o" "../src/testC.c"
../src/testC.c:7:1: warning: useless storage class specifier in empty declaration
    7 | }; MY_ENUM_T /** invoke quickfix -> eclipse freezes*/
      | ^
../src/testC.c:7:13: error: expected ‘;’ before ‘int’
    7 | }; MY_ENUM_T /** invoke quickfix -> eclipse freezes*/
      |             ^
      |             ;
    8 | 
    9 | int main(void) {
      | ~~~          
make: *** [src/subdir.mk:20: src/testC.o] Error 1
"make all" terminated with exit code 2. Build might be incomplete.
'''

> 
> It could help if you can get a stack trace.

Eclipse freezes, while stack trace is not produced in workspace log. I don't know if I can get the stack trace...
Comment 3 Martin Coufal CLA 2020-04-01 11:11:07 EDT
Created attachment 282310 [details]
screenshot
Comment 4 Marco Stornelli CLA 2020-04-01 11:19:00 EDT
QuickFix is triggered by "./src/testC.c:7:13: error: expected ‘;’ before ‘int’". As you can see I haven't got this warning, possible related with Gcc version however. I think you can get a stacktrace anyway debugging eclipse, I don't remember the procedure however.
@Jonah can you help here?
Comment 5 Nathan Ridge CLA 2020-04-01 11:34:33 EDT
You can get a stack trace from a hanging Java process using jstack:

https://wiki.eclipse.org/How_to_report_a_deadlock#Using_jps_.2F_jstack_.28requires_JDK_1.6_or_later.29
Comment 6 Martin Coufal CLA 2020-04-01 11:42:24 EDT
Created attachment 282311 [details]
stack trace
Comment 7 Martin Coufal CLA 2020-04-01 11:42:50 EDT
Thank you both, attaching the stack trace...