optimization/6161: cc1 segfault in make_reorder_chain_1

sstone@tivo.com sstone@tivo.com
Wed Apr 3 16:26:00 GMT 2002


>Number:         6161
>Category:       optimization
>Synopsis:       cc1 segfault in make_reorder_chain_1
>Confidential:   no
>Severity:       serious
>Priority:       medium
>Responsible:    unassigned
>State:          open
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Wed Apr 03 15:36:00 PST 2002
>Closed-Date:
>Last-Modified:
>Originator:     sstone@tivo.com
>Release:        gcc-3.0 and gcc-3.0.4
>Organization:
>Environment:
Redhat Linux 7.2
>Description:
The following small program when run with gcc segfaults when using -O2.  -O1 or less doesn't fail. 

Program t.c:
-----------
struct UI_Event {
        int device;
        char id;
        unsigned long scan_code;
	unsigned long duration;
};


unsigned char map[256];

int x(struct UI_Event* e)
{
        unsigned long fcode = 0;

	if (e->scan_code == 1) {
                switch (e->device) {
                        case 1:
                                fcode = 0;
                                goto done;
                        case 2:
                                fcode = 1;
                                goto done;
                        case 3:
                                fcode = 2;
                                goto done;
                        case 4:
                                fcode = 3;
                                goto done;
                        case 5:
                                fcode = 4;
                                goto done;
                        case 6:
                                fcode = 5;
                                goto done;
                        case 7:
                                fcode = 6;
                                goto done;
                        default:
                                return 0;
                }
	}

        for (fcode = 0; fcode < 256; fcode++) {
                if (e->scan_code == map[fcode]) goto done;
        }
        return 0;

done:
        return 1;
}
-----------
Here is the cc1 backtrace:
Program received signal SIGSEGV, Segmentation fault.
0x081efcc6 in make_reorder_chain_1 (bb=0x82fd198, prev=0x0)
    at ../../gcc-3.0.4/gcc/bb-reorder.c:416
416           next = (taken ? e_taken : e_fall)->dest;
(gdb) bt
#0  0x081efcc6 in make_reorder_chain_1 (bb=0x82fd198, prev=0x0)
    at ../../gcc-3.0.4/gcc/bb-reorder.c:416
#1  0x081efbb8 in make_reorder_chain () at ../../gcc-3.0.4/gcc/bb-reorder.c:328
#2  0x081f0f9e in reorder_basic_blocks ()
    at ../../gcc-3.0.4/gcc/bb-reorder.c:1365
#3  0x0807a560 in rest_of_compilation (decl=0x401c49c0)
    at ../../gcc-3.0.4/gcc/toplev.c:3631
#4  0x0805754e in c_expand_body (fndecl=0x401c49c0, nested_p=0)
    at ../../gcc-3.0.4/gcc/c-decl.c:6782
#5  0x0805742c in finish_function (nested=0)
    at ../../gcc-3.0.4/gcc/c-decl.c:6697
#6  0x08049dfc in yyparse_1 () at c-parse.y:324
#7  0x08078d1a in compile_file (name=0x82f7e92 "t.c")
    at ../../gcc-3.0.4/gcc/toplev.c:2369
#8  0x0807c436 in main (argc=50, argv=0xbffff584)
    at ../../gcc-3.0.4/gcc/toplev.c:4990
#9  0x40048507 in __libc_start_main (main=0x807bd20 <main>, argc=50,
    ubp_av=0xbffff584, init=0x80490b0 <_init>, fini=0x81ff930 <_fini>,
    rtld_fini=0x4000dc14 <_dl_fini>, stack_end=0xbffff57c)
    at ../sysdeps/generic/libc-start.c:129
-----------------------
Run gcc-3-0-4 with the following command line:
gcc -O2 -c t.c
to reproduce.  gcc-3-0 has the same problem.
>How-To-Repeat:
Run gcc-3-0-4 with the following command line:
gcc -O2 -c t.c
to reproduce.  gcc-3-0 has the same problem.
>Fix:

>Release-Note:
>Audit-Trail:
>Unformatted:



More information about the Gcc-bugs mailing list