From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 24601 invoked by alias); 20 Jun 2008 16:40:03 -0000 Received: (qmail 24451 invoked by uid 48); 20 Jun 2008 16:39:16 -0000 Date: Fri, 20 Jun 2008 16:40:00 -0000 Subject: [Bug target/36584] New: Stack is not aligned correctly in recursive function X-Bugzilla-Reason: CC Message-ID: Reply-To: gcc-bugzilla@gcc.gnu.org To: gcc-bugs@gcc.gnu.org From: "ubizjak at gmail dot com" Mailing-List: contact gcc-bugs-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Archive: List-Post: List-Help: Sender: gcc-bugs-owner@gcc.gnu.org X-SW-Source: 2008-06/txt/msg01205.txt.bz2 The example that will be attached in the next comment exhibits a problem with recursive functions. It looks that gcc doesn't align stack correctly if the only remaining call (after inlining?) in the function is the call to itself. Compiling the test source with -O3 -m32 produces: sbisect: -4 -8 pushl %ebp movl %esp, %ebp -12 pushl %edi -16 pushl %esi -20 pushl %ebx -196 subl $176, %esp movl 32(%ebp), %eax ... movl %eax, 4(%esp) 0xC4!! call sbisect movl 40(%ebp), %ecx ... ^^^^ offset from %esp at call site. This violates assumption that %esp is aligned to 16 bytes at call sites. When program recurses into the function, the frame gets unaligned, leading to segfaults when aligned insns are used to access the frame. -- Summary: Stack is not aligned correctly in recursive function Product: gcc Version: 4.4.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: target AssignedTo: unassigned at gcc dot gnu dot org ReportedBy: ubizjak at gmail dot com GCC target triplet: i686-pc-linux-gnu http://gcc.gnu.org/bugzilla/show_bug.cgi?id=36584