Linus Torvalds: GCC 4.9.0 "terminally broken"

    Compilers of the latest generations have become so smart that they almost independently generate code, optimizing everything in a row. Sometimes this leads to unpleasant consequences.

    In the process of preparing the next release candidate in the Linux 3.16 kernel, we found out the completely unpredictable behavior of the load balancing function in Linux 3.16-rc6. On the mailing list for kernel developers, two authors sent messages about different bugs, although they could have a common nature.

    Linus Torvalds carefully sorted out the question and succinctly answered one of the bug reports: “Ok, I looked at the code generation, and your compiler is clean and complete shit .”

    Continuation of the letter of Linus.

    I included Yakub on the mailing list because gcc-4.9.0 seems terminally broken.

    Look, your compiler does absolutely unimaginable things with data crowding out (spilling), including constant crowding out . Lord, this compiler must not leave kindergarten yet. We are talking about a moron who was dropped his head in childhood - such is the level of developmental delay:

    ...
    movq $load_balance_mask, -136(%rbp) #, %sfp
    subq $184, %rsp #,
    movq (%rdx), %rax # sd_22(D)->parent, sd_parent
    movl %edi, -144(%rbp) # this_cpu, %sfp
    movl %ecx, -140(%rbp) # idle, %sfp
    movq %r8, -200(%rbp) # continue_balancing, %sfp
    movq %rax, -184(%rbp) # sd_parent, %sfp
    movq -136(%rbp), %rax # %sfp, tcp_ptr__
    #APP
    add %gs:this_cpu_off, %rax # this_cpu_off, tcp_ptr__
    #NO_APP
    ... 

    Pay attention to the contents -136(%rbp). Really. This is the immediate constant that the compiler has superseded.

    Someone should issue this as a gcc bug. Because damn fucking crazy crap.

    But this part with the displacement of the constant can be considered "too dumb to live." The real bug is here:

    movq $load_balance_mask, -136(%rbp) #, %sfp
    subq $184, %rsp #,

    Here gcc creates a stack frame after using it to save a constant much further than the stack frame.

    In any case, Linus emphasizes, this is not a kernel bug. He suggests creating an official warning for everyone not to use the gcc-4.9.0 compiler, and "Debian users should probably downgrade their new cool compiler."



    PS Comment of a well-informed user a5b : Linus discovered bug 61904 (gcc bugzilla) was closed as a duplicate of bug 61801 . 61801 existed in versions of gcc from 4.5.0 to 4.8.3, 4.9.0 and 4.9.1 (however, until 4.9.0 the error did not lead to the sawing off of the constant in the load_balance code). Fixed since 4.8.4, 4.9.2, 4.10.0. Patch - one line in sched_analyze_2 .

    Also popular now: