[lkml]   [2003]   [Oct]   [14]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
Messages in this thread
    SubjectRe: [x86] Access off the bottom of stack causes a segfault?
    On Tue, 14 Oct 2003, Chris Lattner wrote:

    > > > Generated code:
    > > > .intel_syntax
    > > > ...
    > > > main:
    > > > mov DWORD PTR [%ESP - 16004], %EBP # Save EBP to stack
    > > ^^^^^^^^^^^^
    > >
    > > Yes, this is the problem (even Windows does that IIRC).
    > Ok, I realize what's going on here. The question is, why does the linux
    > kernel consider this to be a bug? Where (in the X86 specs) is it
    > documented that it's illegal to access off the bottom of the stack?
    > My compiler does a nice leaf function optimization where it does not even
    > bother to adjust the stack for leaf functions, which eliminates the adds
    > and subtracts entirely from these (common) functions. This completely
    > invalidates the optimization.
    > Since I'm going to have to live with lots of preexisting kernels, it looks
    > like I'm going to have to disable it entirely, which is disappointing.
    > I'm still curious though why this is thought to be illegal.

    I don't know, I didn't code it :) I discovered it a few months ago while I
    was doing some portable code to measure the maximum stack growth of our
    software. I was doing something like:

    memset(%esp - SAFE, 'S', SIZE);

    and it was puking on me on both Linux and Windows. An alloca+memset solved
    the problem in both environments.

    - Davide

    To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
    the body of a message to
    More majordomo info at
    Please read the FAQ at

     \ /
      Last update: 2005-03-22 13:49    [W:0.043 / U:9.664 seconds]
    ©2003-2016 Jasper Spaans. hosted at Digital OceanAdvertise on this site