public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "christoph dot stueckjuergen at siemens dot com" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug c/26713]  New: Stack frame allocation limited to 32k
Date: Thu, 16 Mar 2006 12:34:00 -0000	[thread overview]
Message-ID: <bug-26713-7757@http.gcc.gnu.org/bugzilla/> (raw)

Allocation of stack frames is limited to a maximum of 32k, regardless of how
much memory is needed by local variables. Addressing of local variables, on the
other hand, is also possible beyond the 32k limit. This can lead to
unpredictable application behavior. No compiler warning is generated. See the C
code below and the commented assembler output.

int main(void)
{
        char array[32770];
        array[0] = 12;
        array[32769] = 34;

        return 0;
}

results in:

10000690 <main>:
10000690:       27bd8020        addiu   sp,sp,-32736    # char array[32770]
                                                        # only results in 32736
                                                        # bytes being allocated
10000694:       ffbe7fd8        sd      s8,32728(sp)
10000698:       ffbc7fd0        sd      gp,32720(sp)
1000069c:       27bdffc0        addiu   sp,sp,-64
100006a0:       03a0f02d        move    s8,sp
100006a4:       3c1c0011        lui     gp,0x11
100006a8:       0399e021        addu    gp,gp,t9
100006ac:       279c82a0        addiu   gp,gp,-32096
100006b0:       2402000c        li      v0,12
100006b4:       a3c20000        sb      v0,0(s8)        # array[0]=12
100006b8:       3c020001        lui     v0,0x1
100006bc:       03c21821        addu    v1,s8,v0        # v1=s8+65536
100006c0:       24020022        li      v0,34
100006c4:       a0628001        sb      v0,-32767(v1)   # array[65536-32767]=34
                                                        # Addressing of local
                                                        # variables is possible
                                                        # beyond the 32k
                                                        # boundary
100006c8:       0000102d        move    v0,zero
100006cc:       27dd0040        addiu   sp,s8,64
100006d0:       dfbe7fd8        ld      s8,32728(sp)
100006d4:       dfbc7fd0        ld      gp,32720(sp)
100006d8:       03e00008        jr      ra
100006dc:       27bd7fe0        addiu   sp,sp,32736


-- 
           Summary: Stack frame allocation limited to 32k
           Product: gcc
           Version: 3.4.3
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: christoph dot stueckjuergen at siemens dot com
 GCC build triplet: x86_64-linux-gnu
  GCC host triplet: x86_64-linux-gnu
GCC target triplet: mips64-linux-gnu


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=26713


             reply	other threads:[~2006-03-16 12:34 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2006-03-16 12:34 christoph dot stueckjuergen at siemens dot com [this message]
2006-03-16 12:38 ` [Bug target/26713] " rguenth at gcc dot gnu dot org
2006-03-16 15:08 ` christoph dot stueckjuergen at siemens dot com
2006-03-21 12:02 ` christoph dot stueckjuergen at siemens dot com
2006-03-21 13:25 ` pinskia at gcc dot gnu dot org

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=bug-26713-7757@http.gcc.gnu.org/bugzilla/ \
    --to=gcc-bugzilla@gcc.gnu.org \
    --cc=gcc-bugs@gcc.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).