This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug target/36584] New: Stack is not aligned correctly in recursive function
- From: "ubizjak at gmail dot com" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: 20 Jun 2008 16:39:16 -0000
- Subject: [Bug target/36584] New: Stack is not aligned correctly in recursive function
- Reply-to: gcc-bugzilla at gcc dot gnu dot org
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