public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug target/36584]  New: Stack is not aligned correctly in recursive function
@ 2008-06-20 16:40 ubizjak at gmail dot com
  2008-06-20 16:40 ` [Bug target/36584] " ubizjak at gmail dot com
                   ` (7 more replies)
  0 siblings, 8 replies; 9+ messages in thread
From: ubizjak at gmail dot com @ 2008-06-20 16:40 UTC (permalink / raw)
  To: gcc-bugs

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


^ permalink raw reply	[flat|nested] 9+ messages in thread

* [Bug target/36584] Stack is not aligned correctly in recursive function
  2008-06-20 16:40 [Bug target/36584] New: Stack is not aligned correctly in recursive function ubizjak at gmail dot com
@ 2008-06-20 16:40 ` ubizjak at gmail dot com
  2008-06-21 13:25 ` [Bug target/36584] [4.3/4.4 Regression] " ubizjak at gmail dot com
                   ` (6 subsequent siblings)
  7 siblings, 0 replies; 9+ messages in thread
From: ubizjak at gmail dot com @ 2008-06-20 16:40 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #1 from ubizjak at gmail dot com  2008-06-20 16:40 -------
Created an attachment (id=15796)
 --> (http://gcc.gnu.org/bugzilla/attachment.cgi?id=15796&action=view)
test case

The testcase, distilled from povray-3.6.1


-- 


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


^ permalink raw reply	[flat|nested] 9+ messages in thread

* [Bug target/36584] [4.3/4.4 Regression] Stack is not aligned correctly in recursive function
  2008-06-20 16:40 [Bug target/36584] New: Stack is not aligned correctly in recursive function ubizjak at gmail dot com
  2008-06-20 16:40 ` [Bug target/36584] " ubizjak at gmail dot com
@ 2008-06-21 13:25 ` ubizjak at gmail dot com
  2008-06-21 16:01 ` hjl dot tools at gmail dot com
                   ` (5 subsequent siblings)
  7 siblings, 0 replies; 9+ messages in thread
From: ubizjak at gmail dot com @ 2008-06-21 13:25 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #2 from ubizjak at gmail dot com  2008-06-21 13:25 -------
Patch at http://gcc.gnu.org/ml/gcc-patches/2008-06/msg01361.html


-- 

ubizjak at gmail dot com changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
         AssignedTo|unassigned at gcc dot gnu   |ubizjak at gmail dot com
                   |dot org                     |
                URL|                            |http://gcc.gnu.org/ml/gcc-
                   |                            |patches/2008-
                   |                            |06/msg01361.html
             Status|UNCONFIRMED                 |ASSIGNED
     Ever Confirmed|0                           |1
   Last reconfirmed|0000-00-00 00:00:00         |2008-06-21 13:25:05
               date|                            |
            Summary|Stack is not aligned        |[4.3/4.4 Regression] Stack
                   |correctly in recursive      |is not aligned correctly in
                   |function                    |recursive function
   Target Milestone|---                         |4.3.2


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


^ permalink raw reply	[flat|nested] 9+ messages in thread

* [Bug target/36584] [4.3/4.4 Regression] Stack is not aligned correctly in recursive function
  2008-06-20 16:40 [Bug target/36584] New: Stack is not aligned correctly in recursive function ubizjak at gmail dot com
  2008-06-20 16:40 ` [Bug target/36584] " ubizjak at gmail dot com
  2008-06-21 13:25 ` [Bug target/36584] [4.3/4.4 Regression] " ubizjak at gmail dot com
@ 2008-06-21 16:01 ` hjl dot tools at gmail dot com
  2008-06-22 11:04 ` jsm28 at gcc dot gnu dot org
                   ` (4 subsequent siblings)
  7 siblings, 0 replies; 9+ messages in thread
From: hjl dot tools at gmail dot com @ 2008-06-21 16:01 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #3 from hjl dot tools at gmail dot com  2008-06-21 16:00 -------
*** Bug 35271 has been marked as a duplicate of this bug. ***


-- 

hjl dot tools at gmail dot com changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |tege-gcc at swox dot com


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


^ permalink raw reply	[flat|nested] 9+ messages in thread

* [Bug target/36584] [4.3/4.4 Regression] Stack is not aligned correctly in recursive function
  2008-06-20 16:40 [Bug target/36584] New: Stack is not aligned correctly in recursive function ubizjak at gmail dot com
                   ` (2 preceding siblings ...)
  2008-06-21 16:01 ` hjl dot tools at gmail dot com
@ 2008-06-22 11:04 ` jsm28 at gcc dot gnu dot org
  2008-06-23 17:37 ` ubizjak at gmail dot com
                   ` (3 subsequent siblings)
  7 siblings, 0 replies; 9+ messages in thread
From: jsm28 at gcc dot gnu dot org @ 2008-06-22 11:04 UTC (permalink / raw)
  To: gcc-bugs



-- 

jsm28 at gcc dot gnu dot org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Priority|P3                          |P1


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


^ permalink raw reply	[flat|nested] 9+ messages in thread

* [Bug target/36584] [4.3/4.4 Regression] Stack is not aligned correctly in recursive function
  2008-06-20 16:40 [Bug target/36584] New: Stack is not aligned correctly in recursive function ubizjak at gmail dot com
                   ` (3 preceding siblings ...)
  2008-06-22 11:04 ` jsm28 at gcc dot gnu dot org
@ 2008-06-23 17:37 ` ubizjak at gmail dot com
  2008-06-24  7:59 ` uros at gcc dot gnu dot org
                   ` (2 subsequent siblings)
  7 siblings, 0 replies; 9+ messages in thread
From: ubizjak at gmail dot com @ 2008-06-23 17:37 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #4 from ubizjak at gmail dot com  2008-06-23 17:36 -------
Author: uros
Date: Mon Jun 23 17:31:12 2008
New Revision: 137045

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=137045
Log:
        PR middle-end/PR36584
        * calls.c (expand_call): Increase alignment for recursive functions.

testsuite/ChangeLog:

        PR middle-end/PR36584
        * testsuite/gcc.dg/pr36584.c: New test.
        * testsuite/gcc.target/i386/local2.c: Remove invalid test.


Added:
    trunk/gcc/testsuite/gcc.dg/pr36584.c
Removed:
    trunk/gcc/testsuite/gcc.target/i386/local2.c
Modified:
    trunk/gcc/ChangeLog
    trunk/gcc/calls.c
    trunk/gcc/testsuite/ChangeLog


-- 


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


^ permalink raw reply	[flat|nested] 9+ messages in thread

* [Bug target/36584] [4.3/4.4 Regression] Stack is not aligned correctly in recursive function
  2008-06-20 16:40 [Bug target/36584] New: Stack is not aligned correctly in recursive function ubizjak at gmail dot com
                   ` (4 preceding siblings ...)
  2008-06-23 17:37 ` ubizjak at gmail dot com
@ 2008-06-24  7:59 ` uros at gcc dot gnu dot org
  2008-06-24  8:02 ` ubizjak at gmail dot com
  2008-06-27 14:00 ` hjl at gcc dot gnu dot org
  7 siblings, 0 replies; 9+ messages in thread
From: uros at gcc dot gnu dot org @ 2008-06-24  7:59 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #5 from uros at gcc dot gnu dot org  2008-06-24 07:59 -------
Subject: Bug 36584

Author: uros
Date: Tue Jun 24 07:58:17 2008
New Revision: 137059

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=137059
Log:
        PR middle-end/36584
        * calls.c (expand_call): Increase alignment for recursive functions.

testsuite/ChangeLog:

        PR middle-end/36584
        * testsuite/gcc.dg/pr36584.c: New test.
        * testsuite/gcc.target/i386/local2.c: Remove invalid test.


Added:
    branches/gcc-4_3-branch/gcc/testsuite/gcc.dg/pr36584.c
      - copied, changed from r137045, trunk/gcc/testsuite/gcc.dg/pr36584.c
Removed:
    branches/gcc-4_3-branch/gcc/testsuite/gcc.target/i386/local2.c
Modified:
    branches/gcc-4_3-branch/gcc/ChangeLog
    branches/gcc-4_3-branch/gcc/calls.c
    branches/gcc-4_3-branch/gcc/testsuite/ChangeLog


-- 


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


^ permalink raw reply	[flat|nested] 9+ messages in thread

* [Bug target/36584] [4.3/4.4 Regression] Stack is not aligned correctly in recursive function
  2008-06-20 16:40 [Bug target/36584] New: Stack is not aligned correctly in recursive function ubizjak at gmail dot com
                   ` (5 preceding siblings ...)
  2008-06-24  7:59 ` uros at gcc dot gnu dot org
@ 2008-06-24  8:02 ` ubizjak at gmail dot com
  2008-06-27 14:00 ` hjl at gcc dot gnu dot org
  7 siblings, 0 replies; 9+ messages in thread
From: ubizjak at gmail dot com @ 2008-06-24  8:02 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #6 from ubizjak at gmail dot com  2008-06-24 08:02 -------
Fixed for mainline and 4.3 branch.


-- 

ubizjak at gmail dot com changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|ASSIGNED                    |RESOLVED
         Resolution|                            |FIXED


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


^ permalink raw reply	[flat|nested] 9+ messages in thread

* [Bug target/36584] [4.3/4.4 Regression] Stack is not aligned correctly in recursive function
  2008-06-20 16:40 [Bug target/36584] New: Stack is not aligned correctly in recursive function ubizjak at gmail dot com
                   ` (6 preceding siblings ...)
  2008-06-24  8:02 ` ubizjak at gmail dot com
@ 2008-06-27 14:00 ` hjl at gcc dot gnu dot org
  7 siblings, 0 replies; 9+ messages in thread
From: hjl at gcc dot gnu dot org @ 2008-06-27 14:00 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #7 from hjl at gcc dot gnu dot org  2008-06-27 13:59 -------
Subject: Bug 36584

Author: hjl
Date: Fri Jun 27 13:59:05 2008
New Revision: 137179

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=137179
Log:
2008-06-27  H.J. Lu  <hongjiu.lu@intel.com>

        PR middle-end/36584
        * gcc.target/i386/stackalign/local-1.c: Remove invalid test.

Removed:
    branches/stack/gcc/testsuite/gcc.target/i386/stackalign/local-1.c
Modified:
    branches/stack/gcc/testsuite/ChangeLog.stackalign


-- 


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


^ permalink raw reply	[flat|nested] 9+ messages in thread

end of thread, other threads:[~2008-06-27 14:00 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2008-06-20 16:40 [Bug target/36584] New: Stack is not aligned correctly in recursive function ubizjak at gmail dot com
2008-06-20 16:40 ` [Bug target/36584] " ubizjak at gmail dot com
2008-06-21 13:25 ` [Bug target/36584] [4.3/4.4 Regression] " ubizjak at gmail dot com
2008-06-21 16:01 ` hjl dot tools at gmail dot com
2008-06-22 11:04 ` jsm28 at gcc dot gnu dot org
2008-06-23 17:37 ` ubizjak at gmail dot com
2008-06-24  7:59 ` uros at gcc dot gnu dot org
2008-06-24  8:02 ` ubizjak at gmail dot com
2008-06-27 14:00 ` hjl at gcc dot gnu dot org

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).