public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug target/49437] New: interrupt return pop sometimes corrupts sp
@ 2011-06-16 11:56 domen at cba dot si
  2011-06-24 16:18 ` [Bug target/49437] " ramana at gcc dot gnu.org
                   ` (5 more replies)
  0 siblings, 6 replies; 7+ messages in thread
From: domen at cba dot si @ 2011-06-16 11:56 UTC (permalink / raw)
  To: gcc-bugs

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

           Summary: interrupt return pop sometimes corrupts sp
           Product: gcc
           Version: 4.5.3
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: target
        AssignedTo: unassigned@gcc.gnu.org
        ReportedBy: domen@cba.si


Simple to reproduce, it seems >=5 arguments with any of printf* can cause this.
Some code around it was left, as it does not happen otherwise.

$ cat bug.c 
#include <stdio.h>

char *pending_messages_put_start(void);
void pending_messages_put_final(void);

void __attribute__((interrupt)) TIM7_IRQHandler(void)
{
        char *msg = pending_messages_put_start();
        snprintf(msg, 20, "%i %i", 1, 1);
        pending_messages_put_final();
}
$ arm-none-eabi-gcc -Wall -Os -S bug.c
$ cat bug.s 
        .syntax unified
        .arch armv7-m
        .fpu softvfp
        .eabi_attribute 20, 1
        .eabi_attribute 21, 1
        .eabi_attribute 23, 3
        .eabi_attribute 24, 1
        .eabi_attribute 25, 1
        .eabi_attribute 26, 1
        .eabi_attribute 30, 4
        .eabi_attribute 18, 4
        .thumb
        .file   "bug.c"
        .text
        .align  1
        .global TIM7_IRQHandler
        .thumb
        .thumb_func
        .type   TIM7_IRQHandler, %function
TIM7_IRQHandler:
        @ Stack Align: May be called with mis-aligned SP.
        @ args = 0, pretend = 0, frame = 0
        @ frame_needed = 0, uses_anonymous_args = 0
        mov     r0, sp
        bic     r1, r0, #7
        mov     sp, r1
        push    {r0, lr}
        sub     sp, sp, #8
        bl      pending_messages_put_start
        movs    r3, #1
        movs    r1, #20
        ldr     r2, .L2
        str     r3, [sp, #0]
        bl      snprintf
        bl      pending_messages_put_final
        pop     {r0, r2, r3, lr}    // <-- r3 is in place of r0; expected would
be add sp, sp, #8, pop {r0, lr}, I guess
        mov     sp, r0
        bx      lr
.L3:
        .align  2
.L2:
        .word   .LC0
        .size   TIM7_IRQHandler, .-TIM7_IRQHandler
        .section        .rodata.str1.1,"aMS",%progbits,1
.LC0:
        .ascii  "%i %i\000"
        .ident  "GCC: (GNU) 4.5.3"


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

* [Bug target/49437] interrupt return pop sometimes corrupts sp
  2011-06-16 11:56 [Bug target/49437] New: interrupt return pop sometimes corrupts sp domen at cba dot si
@ 2011-06-24 16:18 ` ramana at gcc dot gnu.org
  2011-08-03  0:47 ` joey.ye at arm dot com
                   ` (4 subsequent siblings)
  5 siblings, 0 replies; 7+ messages in thread
From: ramana at gcc dot gnu.org @ 2011-06-24 16:18 UTC (permalink / raw)
  To: gcc-bugs

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

Ramana Radhakrishnan <ramana at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Keywords|                            |wrong-code
             Status|UNCONFIRMED                 |NEW
   Last reconfirmed|                            |2011.06.24 16:18:22
                 CC|                            |ramana at gcc dot gnu.org
     Ever Confirmed|0                           |1
      Known to fail|                            |4.7.0

--- Comment #1 from Ramana Radhakrishnan <ramana at gcc dot gnu.org> 2011-06-24 16:18:22 UTC ---
Confirmed - trunk generates this code as well. It has to do with the handling
of IS_STACKALIGN in arm_output_epilogue when it optimizes for size.



Ramana


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

* [Bug target/49437] interrupt return pop sometimes corrupts sp
  2011-06-16 11:56 [Bug target/49437] New: interrupt return pop sometimes corrupts sp domen at cba dot si
  2011-06-24 16:18 ` [Bug target/49437] " ramana at gcc dot gnu.org
@ 2011-08-03  0:47 ` joey.ye at arm dot com
  2011-08-19  8:32 ` jye2 at gcc dot gnu.org
                   ` (3 subsequent siblings)
  5 siblings, 0 replies; 7+ messages in thread
From: joey.ye at arm dot com @ 2011-08-03  0:47 UTC (permalink / raw)
  To: gcc-bugs

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

Joey Ye <joey.ye at arm dot com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |joey.ye at arm dot com

--- Comment #2 from Joey Ye <joey.ye at arm dot com> 2011-08-03 00:47:10 UTC ---
A patch and test case is available at
http://gcc.gnu.org/ml/gcc-patches/2011-08/msg00244.html


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

* [Bug target/49437] interrupt return pop sometimes corrupts sp
  2011-06-16 11:56 [Bug target/49437] New: interrupt return pop sometimes corrupts sp domen at cba dot si
  2011-06-24 16:18 ` [Bug target/49437] " ramana at gcc dot gnu.org
  2011-08-03  0:47 ` joey.ye at arm dot com
@ 2011-08-19  8:32 ` jye2 at gcc dot gnu.org
  2011-09-19 11:06 ` jye2 at gcc dot gnu.org
                   ` (2 subsequent siblings)
  5 siblings, 0 replies; 7+ messages in thread
From: jye2 at gcc dot gnu.org @ 2011-08-19  8:32 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #3 from jye2 at gcc dot gnu.org 2011-08-19 08:28:15 UTC ---
Author: jye2
Date: Fri Aug 19 08:28:08 2011
New Revision: 177891

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=177891
Log:
       PR target/49437
       * config/arm/arm.c (arm_output_epilogue): Properly handle epilogue
       when stack was realigned in interrupt handler prologue.

testsuite:

       PR target/49437
       * gcc.target/arm/handler-align.c: New test.
       * lib/target-supports.exp (check_effective_target_arm_cortex_m):
         New Function.


Added:
    trunk/gcc/testsuite/gcc.target/arm/handler-align.c
Modified:
    trunk/gcc/ChangeLog
    trunk/gcc/config/arm/arm.c
    trunk/gcc/testsuite/ChangeLog
    trunk/gcc/testsuite/lib/target-supports.exp


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

* [Bug target/49437] interrupt return pop sometimes corrupts sp
  2011-06-16 11:56 [Bug target/49437] New: interrupt return pop sometimes corrupts sp domen at cba dot si
                   ` (2 preceding siblings ...)
  2011-08-19  8:32 ` jye2 at gcc dot gnu.org
@ 2011-09-19 11:06 ` jye2 at gcc dot gnu.org
  2012-07-31  1:05 ` ramana at gcc dot gnu.org
  2015-06-24 23:48 ` ramana at gcc dot gnu.org
  5 siblings, 0 replies; 7+ messages in thread
From: jye2 at gcc dot gnu.org @ 2011-09-19 11:06 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #4 from jye2 at gcc dot gnu.org 2011-09-19 09:03:35 UTC ---
Author: jye2
Date: Mon Sep 19 09:03:29 2011
New Revision: 178963

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=178963
Log:
2011-09-19  Joey Ye  <joey.ye@arm.com>

    Backport r177891 from mainline
    2011-08-19 Matthew Gretton-Dann  <matthew.gretton-dann@arm.com>

    PR target/49437
    * config/arm/arm.c (arm_output_epilogue): Properly handle epilogue
    when stack was realigned in interrupt handler prologue.

testsuite:

    2011-08-19 Joey Ye  <joey.ye@arm.com>
    PR target/49437
    * gcc.target/arm/handler-align.c: New test.
    * lib/target-supports.exp (check_effective_target_arm_cortex_m):
    New Function.

2011-09-19  Joey Ye  <joey.ye@arm.com>

    Backport r177890 from mainline
    2011-08-19  Joey Ye  <joey.ye@arm.com>

    * gcc.c-torture/execute/20101011-1.c (DO_TEST): Skip on ARM.


Added:
    branches/ARM/embedded-4_6-branch/gcc/testsuite/ChangeLog.arm
    branches/ARM/embedded-4_6-branch/gcc/testsuite/gcc.dg/torture/pr49169.c
   
branches/ARM/embedded-4_6-branch/gcc/testsuite/gcc.target/arm/handler-align.c
    branches/ARM/embedded-4_6-branch/gcc/testsuite/gcc.target/arm/pr46934.c
Modified:
    branches/ARM/embedded-4_6-branch/gcc/ChangeLog.arm
    branches/ARM/embedded-4_6-branch/gcc/config/arm/arm.c
   
branches/ARM/embedded-4_6-branch/gcc/testsuite/gcc.c-torture/execute/20101011-1.c
    branches/ARM/embedded-4_6-branch/gcc/testsuite/lib/target-supports.exp


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

* [Bug target/49437] interrupt return pop sometimes corrupts sp
  2011-06-16 11:56 [Bug target/49437] New: interrupt return pop sometimes corrupts sp domen at cba dot si
                   ` (3 preceding siblings ...)
  2011-09-19 11:06 ` jye2 at gcc dot gnu.org
@ 2012-07-31  1:05 ` ramana at gcc dot gnu.org
  2015-06-24 23:48 ` ramana at gcc dot gnu.org
  5 siblings, 0 replies; 7+ messages in thread
From: ramana at gcc dot gnu.org @ 2012-07-31  1:05 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #5 from Ramana Radhakrishnan <ramana at gcc dot gnu.org> 2012-07-31 01:05:18 UTC ---
Fixed only in 4.7.0

Ramana


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

* [Bug target/49437] interrupt return pop sometimes corrupts sp
  2011-06-16 11:56 [Bug target/49437] New: interrupt return pop sometimes corrupts sp domen at cba dot si
                   ` (4 preceding siblings ...)
  2012-07-31  1:05 ` ramana at gcc dot gnu.org
@ 2015-06-24 23:48 ` ramana at gcc dot gnu.org
  5 siblings, 0 replies; 7+ messages in thread
From: ramana at gcc dot gnu.org @ 2015-06-24 23:48 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=49437

Ramana Radhakrishnan <ramana at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
         Resolution|---                         |FIXED
   Target Milestone|---                         |4.7.0

--- Comment #6 from Ramana Radhakrishnan <ramana at gcc dot gnu.org> ---
fixed in 4.7.0


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

end of thread, other threads:[~2015-06-24 23:48 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-06-16 11:56 [Bug target/49437] New: interrupt return pop sometimes corrupts sp domen at cba dot si
2011-06-24 16:18 ` [Bug target/49437] " ramana at gcc dot gnu.org
2011-08-03  0:47 ` joey.ye at arm dot com
2011-08-19  8:32 ` jye2 at gcc dot gnu.org
2011-09-19 11:06 ` jye2 at gcc dot gnu.org
2012-07-31  1:05 ` ramana at gcc dot gnu.org
2015-06-24 23:48 ` ramana at gcc dot gnu.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).