From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 7746 invoked by alias); 16 Mar 2006 12:34:45 -0000 Received: (qmail 7730 invoked by uid 48); 16 Mar 2006 12:34:42 -0000 Date: Thu, 16 Mar 2006 12:34:00 -0000 Subject: [Bug c/26713] New: Stack frame allocation limited to 32k X-Bugzilla-Reason: CC Message-ID: Reply-To: gcc-bugzilla@gcc.gnu.org To: gcc-bugs@gcc.gnu.org From: "christoph dot stueckjuergen at siemens dot com" Mailing-List: contact gcc-bugs-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Archive: List-Post: List-Help: Sender: gcc-bugs-owner@gcc.gnu.org X-SW-Source: 2006-03/txt/msg01681.txt.bz2 List-Id: 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
: 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