Bug 42452 - The application stack can be corrupted when an interrupt occurs somewhere
Summary: The application stack can be corrupted when an interrupt occurs somewhere
Status: RESOLVED DUPLICATE of bug 38644
Alias: None
Product: gcc
Classification: Unclassified
Component: target (show other bugs)
Version: 4.4.1
: P3 normal
Target Milestone: ---
Assignee: Not yet assigned to anyone
URL:
Keywords: wrong-code
Depends on:
Blocks:
 
Reported: 2009-12-21 21:18 UTC by Chengfa Wang
Modified: 2009-12-21 21:46 UTC (History)
6 users (show)

See Also:
Host:
Target: arm*-*-*
Build:
Known to work:
Known to fail:
Last reconfirmed:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Chengfa Wang 2009-12-21 21:18:53 UTC
The options given when GCC was configured/built:
Using built-in specs.
Target: arm-none-eabi
Configured with: /scratch/julian/2009q3-respin-eabi-lite/src/gcc-4.4/configure --build=i686-pc-linux-gnu --host=i686-min
gw32 --target=arm-none-eabi --enable-threads --disable-libmudflap --disable-libssp --disable-libstdcxx-pch --enable-extr
a-sgxxlite-multilibs --with-gnu-as --with-gnu-ld --with-specs='%{O2:%{!fno-remove-local-statics: -fremove-local-statics}
} %{O*:%{O|O0|O1|O2|Os:;:%{!fno-remove-local-statics: -fremove-local-statics}}}' --enable-languages=c,c++ --disable-shar
ed --disable-lto --with-newlib --with-pkgversion='Sourcery G++ Lite 2009q3-68' --with-bugurl=https://support.codesourcer
y.com/GNUToolchain/ --disable-nls --prefix=/opt/codesourcery --with-headers=yes --with-sysroot=/opt/codesourcery/arm-non
e-eabi --with-build-sysroot=/scratch/julian/2009q3-respin-eabi-lite/install/host-i686-mingw32/arm-none-eabi --with-libic
onv-prefix=/scratch/julian/2009q3-respin-eabi-lite/obj/host-libs-2009q3-68-arm-none-eabi-i686-mingw32/usr --with-gmp=/sc
ratch/julian/2009q3-respin-eabi-lite/obj/host-libs-2009q3-68-arm-none-eabi-i686-mingw32/usr --with-mpfr=/scratch/julian/
2009q3-respin-eabi-lite/obj/host-libs-2009q3-68-arm-none-eabi-i686-mingw32/usr --with-ppl=/scratch/julian/2009q3-respin-
eabi-lite/obj/host-libs-2009q3-68-arm-none-eabi-i686-mingw32/usr --with-host-libstdcxx='-static-libgcc -Wl,-Bstatic,-lst
dc++,-Bdynamic -lm' --with-cloog=/scratch/julian/2009q3-respin-eabi-lite/obj/host-libs-2009q3-68-arm-none-eabi-i686-ming
w32/usr --disable-libgomp --enable-poison-system-directories --with-build-time-tools=/scratch/julian/2009q3-respin-eabi-
lite/obj/tools-i686-pc-linux-gnu-2009q3-68-arm-none-eabi-i686-mingw32/arm-none-eabi/bin --with-build-time-tools=/scratch
/julian/2009q3-respin-eabi-lite/obj/tools-i686-pc-linux-gnu-2009q3-68-arm-none-eabi-i686-mingw32/arm-none-eabi/bin
Thread model: single
gcc version 4.4.1 (Sourcery G++ Lite 2009q3-68)


0011c6d0 <getFPGARefRate>:
  11c6d0:	b510      	push	{r4, lr}
  11c6d2:	b082      	sub	sp, #8
  11c6d4:	466c      	mov	r4, sp
  11c6d6:	3406      	adds	r4, #6
  11c6d8:	201d      	movs	r0, #29
  11c6da:	1c21      	adds	r1, r4, #0
  11c6dc:	2201      	movs	r2, #1
  11c6de:	f7ff ff6f 	bl	11c5c0 <readFPGA>
  11c6e2:	b002      	add	sp, #8
  11c6e4:	8820      	ldrh	r0, [r4, #0]
  11c6e6:	bc10      	pop	{r4}
  11c6e8:	bc02      	pop	{r1}
  11c6ea:	4708      	bx	r

The returned value (r0) of the above function will be overwritten when an interrupt occurs between address 11c6e2 and address 11c6e4 and the interrupt service routine shares same stack with the above function. I think the quick fix is to swap the instructions between address 11c6e2 and address 11c6e4.
Comment 1 Chengfa Wang 2009-12-21 21:27:51 UTC
Actually, The value which r4 points to in the above function will be corrupted when an interrupt occurs between address 11c6e2 and address 11c6e4 and the interrupt service routine shares a same stack with the above function.
Comment 2 Andrew Pinski 2009-12-21 21:46:54 UTC

*** This bug has been marked as a duplicate of 38644 ***