Re: [bug] crash when reading /proc/mounts (was: Re: Linux 2.6.23-rc9 and a heads-up for the 2.6.24 series..)

Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]
From: Linus Torvalds
Date: Wednesday, October 3, 2007 - 8:47 am

On Wed, 3 Oct 2007, Linus Torvalds wrote:

Btw, this definitely doesn't happen for me, either on x86-64 or plain x86. 
The x86 thing I tested was Fedora 8 testing (ie not even some stable 
setup), so I wonder what experimental compiler you have.

Your compiler generates

	movl    -16(%ebp),%edx
	movl    (%edx),%edi		/* this is _totally_ bogus! */
	incl    %edx
	movl    %edx,-16(%ebp)
	movl    %edi,%ecx
	testb   %cl,%cl
	je      ...

while I get (gcc version 4.1.2 20070925 (Red Hat 4.1.2-28)):

        movl    -16(%ebp), %eax # p,
        movzbl  (%eax), %edi    #, c	/* not bogus! */
        movl    %edi, %edx      # c,
        testb   %dl, %dl        #
        je      .L64    #,
        incl    %eax    #
        movsbl  %dl,%ebx        #, D.12414
        movl    %eax, -16(%ebp) #, p

where the difference (apart from doing the increment differently and 
different register allocation) is that I have a "movzbl" (correct), while 
you have a "movl" (pure and utter crap).

I *suspect* that the compiler bug is along the lines of:
 (a) start off with movzbl
 (b) notice that the higher bits don't matter, because nobody subsequently 
     uses them
 (c) turn the thing into just a byte move. 
 (d) make the totally incorrect optimization of using a full 32-bit move 
     in order to avoid a partial register access stall

and the thing is, that final optimization can actually speed things up 
(although it can also slow things down for any access that crosses a cache 
sector boundary - 8/16 bytes), but it's seriously bogus, exactly because 
it can cause an invalid access to the three next bytes that may not even 
exist.

			Linus
-
Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]

Messages in current thread:
Linux 2.6.23-rc9 and a heads-up for the 2.6.24 series.., Linus Torvalds, (Mon Oct 1, 8:41 pm)
Re: Linux 2.6.23-rc9 and a heads-up for the 2.6.24 series.., Rafael J. Wysocki, (Tue Oct 2, 1:12 pm)
Re: Linux 2.6.23-rc9 and a heads-up for the 2.6.24 series.., Rafael J. Wysocki, (Tue Oct 2, 1:31 pm)
Re: Linux 2.6.23-rc9 and a heads-up for the 2.6.24 series.., Alistair John Strachan, (Tue Oct 2, 3:51 pm)
Re: Linux 2.6.23-rc9 and a heads-up for the 2.6.24 series.., Glauber de Oliveira ..., (Tue Oct 2, 4:00 pm)
Re: [bug] crash when reading /proc/mounts (was: Re: Linux ..., Linus Torvalds, (Wed Oct 3, 8:47 am)
[patch] net, 9p: build fix with !CONFIG_SYSCTL, Ingo Molnar, (Thu Oct 4, 4:55 am)
[BUG] Linux 2.6.23-rc9 and MAX_ARG_PAGES, Mathieu Chouquet-Str ..., (Thu Oct 4, 10:05 am)
Re: [BUG] Linux 2.6.23-rc9 and MAX_ARG_PAGES, Peter Zijlstra, (Thu Oct 4, 10:17 am)
Re: [BUG] Linux 2.6.23-rc9 and MAX_ARG_PAGES, Linus Torvalds, (Thu Oct 4, 10:27 am)
Re: [BUG] Linux 2.6.23-rc9 and MAX_ARG_PAGES, Mathieu Chouquet-Str ..., (Thu Oct 4, 1:44 pm)
Re: [BUG] Linux 2.6.23-rc9 and MAX_ARG_PAGES, Mathieu Chouquet-Str ..., (Thu Oct 4, 1:47 pm)
Re: [BUG] Linux 2.6.23-rc9 and MAX_ARG_PAGES, Linus Torvalds, (Thu Oct 4, 2:21 pm)
Re: [BUG] Linux 2.6.23-rc9 and MAX_ARG_PAGES, Chuck Ebbert, (Thu Oct 4, 2:50 pm)
Re: [BUG] Linux 2.6.23-rc9 and MAX_ARG_PAGES, Mathieu Chouquet-Str ..., (Thu Oct 4, 2:54 pm)
Re: [BUG] Linux 2.6.23-rc9 and MAX_ARG_PAGES, Mathieu Chouquet-Str ..., (Thu Oct 4, 2:58 pm)
Re: [BUG] Linux 2.6.23-rc9 and MAX_ARG_PAGES, Paul Mackerras, (Thu Oct 4, 3:27 pm)
Re: [BUG] Linux 2.6.23-rc9 and MAX_ARG_PAGES, Linus Torvalds, (Thu Oct 4, 5:12 pm)
Re: [BUG] Linux 2.6.23-rc9 and MAX_ARG_PAGES, Mathieu Chouquet-Str ..., (Thu Oct 4, 8:22 pm)
Re: [BUG] Linux 2.6.23-rc9 and MAX_ARG_PAGES, Peter Zijlstra, (Fri Oct 5, 12:43 am)
Re: [BUG] Linux 2.6.23-rc9 and MAX_ARG_PAGES, Hans-Peter Jansen, (Sat Oct 6, 1:29 am)
Re: [BUG] Linux 2.6.23-rc9 and MAX_ARG_PAGES, Hans-Peter Jansen, (Sat Oct 6, 4:29 am)
Re: [BUG] Linux 2.6.23-rc9 and MAX_ARG_PAGES, Bill Davidsen, (Sat Oct 6, 10:36 am)
Re: Linux 2.6.23-rc9 and a heads-up for the 2.6.24 series.., Alistair John Strachan, (Sun Oct 7, 4:44 pm)