📜 ⬆️ ⬇️

Linus Torvalds: GCC 4.9.0 "terminally broken"

Compilers of the latest generations have become so clever that they generate code almost independently, optimizing everything. Sometimes it leads to unpleasant consequences.

During the preparation of the next release candidate in the Linux 3.16 kernel, the completely unpredictable behavior of the load-balancing function in Linux 3.16-rc6 was discovered. On the mailing list for kernel developers, two authors sent messages about various bugs, although they could have a common nature.

Linus Torvalds carefully figured out the question and succinctly answered one of those who reported the bug: “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 incurable broken.

Look, your compiler does absolutely inconceivable things with the repression (spilling) of data, including the extrusion of a constant . Lord, this compiler cannot be yet out of kindergarten. We are talking about a moron who was dropped by a head in childhood - this is the level of developmental delays:

... 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 ... 

Notice the contents of -136(%rbp) . Realistically. This is an immediate constant that the compiler has supplanted.

Someone should fix this as a gcc bug. Because it is fucking fucking crazy crap.

But this part with the repression of the constant can be considered "too stupid to live." This bug is here:

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

Here gcc creates a stack frame after using it to save the 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 in no case using the gcc-4.9.0 compiler, and "Debian users should probably downgrade their new cool compiler."



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

Source: https://habr.com/ru/post/231243/


All Articles