This is the mail archive of the
gcc-help@gcc.gnu.org
mailing list for the GCC project.
subl $<large number>, %esp related segfault
- From: TPCnospam at mklab dot ph dot rhul dot ac dot uk
- To: gcc-help at gcc dot gnu dot org
- Cc: tom at mklab dot ph dot rhul dot ac dot uk (Tom Crane)
- Date: Wed, 25 Aug 2004 21:45:38 +0100 (BST)
- Subject: subl $<large number>, %esp related segfault
- Reply-to: TPCnospam at mklab dot ph dot rhul dot ac dot uk
Dear All,
I am getting segfaults in a FORTRAN program compiled with g95
under Linux/i386 but the problem is not specific to g95. I can simulate
it with g77 which similarly uses gcc's assembler generation routines. It
is just that I have some quite large subroutines (originally Fortran 77)
which been trivially converted to use a derived datatype under g95 which
has the effect of substantially increasing the code size and memory usage
-- to the extent that the problem I'm describing occurs. The problem
subroutines are part of a set of similar, numerically intensive ones, most
of which work fine. It is just the few biggest ones which have this
problem. Here is some assembler O/P from g95 for a problem subroutine.
.type fo7dma0dmc0_, @function
fo7dma0dmc0_:
.LFB93:
.loc 1 1 0
pushl %ebp
.LCFI315:
movl %esp, %ebp
.LCFI316:
pushl %edi
.LCFI317:
pushl %esi
.LCFI318:
pushl %ebx
.LCFI319:
subl $9389456, %esp
.LCFI320:
.loc 2 20 0
.LBB47:
pushl $3
pushl $.LC0
etc. etc.
Here is my analysis: The 'subl $9389456, %esp' pulls the stack pointer
down by that large number. When the 'pushl $3' tries to execute it
overflows the stack and gets a segfault. My FORTRAN code uses static
allocation. The thing I don't understand is; what precisely is the subl's
purpose? Is there a way to reduce its size? eg. a compiler option. I'm
reluctant to try splitting the subroutine up into two smaller ones.
Any other ideas?
Thanks
Tom.
Ps. Where can I find a description of GNU/Linux procedure calling
standard?
--
Tom Crane, Dept. Physics, Royal Holloway, University of London, Egham Hill,
Egham, Surrey, TW20 0EX, England.
Email: T.Crane@rhul.ac.uk
Fax: +44 (0) 1784 472794