🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.lang.c.moderated
Article #2608

Re: Legal alloca?

#2608
From: Joachim Huober
Date: Wed, 17 Apr 1996 15:44
36 lines
2068 bytes
In article <4l1h2l$pns@solutions.solon.com>, schwarz@mips.complang.tuwien.ac.at (Konrad Schwarz) writes:
|> In article <4koe4u$8sl@solutions.solon.com>,
|> wirzeniu@cc.helsinki.fi (Lars Wirzenius) writes:
|> 
|> |> 		int *temp;
|> |> 
|> |> 		temp = alloca(bar*sizeof(int));
|> |> 		if (temp == NULL)
|> |> 			return -1;
|> 
|> I have never seen a man page indicating that alloca can fail in the same
|> way as malloc.  I expect a SIGSEGV signal to be posted when stack extension
|> is no longer possible.  (I think this is a feature, since there is usually not
|> much you can do except terminate when memory runs out, anyhow.)
On solaris the man page says about this:
     alloca() allocates size bytes of space in the stack frame of
     the  caller,  and  returns a pointer to the allocated block.
     This temporary space is automatically freed when the  caller
     returns.  Note: if the allocated block is beyond the current
     stack limit, the resulting behavior is undefined.

     alloca() is machine-, compiler-, and most  of  all,  system-
     dependent.  Its use is strongly discouraged.

As far as I know, a stack overflow generates a SIGILL.
On SGI si_code is set to ILL_BADSTK.
|> 
|> Konrad Schwarz

Joachim
-- 
---------------------------------------------------------------------
Joachim Huober                                Phone: +49 731 502-6241
UDINE-Project,            URZ, University of Ulm, 89081 Ulm , Germany
E-mail: joachim.huober@rz.uni-ulm.de 
---------------------------------------------------------------------
Technical Details
Message-ID: <4l33km$7ne@solutions.solon.com>
Path: arc1-ca.pugleaf.net!solon.com!not-for-mail
References: <4klidc$ne8@solutions.solon.com> <4koe4u$8sl@solutions.solon.com> <4l1h2l$pns@solutions.solon.com>

Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!solon.com!not-for-mail
From: huober_j@spica.rz.uni-ulm.de (Joachim Huober)
Newsgroups: comp.lang.c.moderated
Subject: Re: Legal alloca?
Date: 17 Apr 1996 10:44:22 -0500
Organization: Universitaet Ulm
Sender: clc@solutions.solon.com
Approved: clc@solutions.solon.com
Message-ID: <4l33km$7ne@solutions.solon.com>
References: <4klidc$ne8@solutions.solon.com> <4koe4u$8sl@solutions.solon.com> <4l1h2l$pns@solutions.solon.com>
NNTP-Posting-Host: solutions.solon.com