public inbox for gcc-help@gcc.gnu.org
 help / color / mirror / Atom feed
* subl $<large number>, %esp related segfault
@ 2004-08-25 23:47 TPCnospam
  2004-08-26  7:28 ` Arno Wilhelm
  0 siblings, 1 reply; 2+ messages in thread
From: TPCnospam @ 2004-08-25 23:47 UTC (permalink / raw)
  To: gcc-help; +Cc: Tom Crane

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

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

* Re: subl $<large number>, %esp related segfault
  2004-08-25 23:47 subl $<large number>, %esp related segfault TPCnospam
@ 2004-08-26  7:28 ` Arno Wilhelm
  0 siblings, 0 replies; 2+ messages in thread
From: Arno Wilhelm @ 2004-08-26  7:28 UTC (permalink / raw)
  To: TPCnospam; +Cc: gcc-help, Tom Crane


> Ps. Where can I find a description of GNU/Linux procedure calling 
> standard?

Here is a lot of documentation:

http://linuxassembly.org/resources.html#docs
http://linuxassembly.org/intro/hello.html#AEN55


Arno

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

end of thread, other threads:[~2004-08-26  6:46 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2004-08-25 23:47 subl $<large number>, %esp related segfault TPCnospam
2004-08-26  7:28 ` Arno Wilhelm

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