This is the mail archive of the
cygwin-developers
mailing list for the Cygwin project.
Re: stack overflow bug in ofstream::operator<<
On Tue, Jun 28, 2005 at 06:41:09PM +0100, Dave Korn wrote:
>Well, I was proposing testing how much space was available on the
>stack, so that we never alloca past the bottom of it, and hence don't
>*need* any kind of signal handler.
If we are going to check how much stack space is available, it might be
nice to make a __alloca_which_returns_NULL which returns NULL when there
isn't enough space available. That could be used for other things.
OTOH, the functionality I'm adding would allow you to do this:
.
.
.
{
char *p;
bool malloced;
myfault efault;
if (efault.faulted ())
{
p = malloc (n);
malloced = true;
}
else
{
p = alloca (n);
malloced = false;
}
}
If alloca actually SEGVs when it tries to allocate too much space then
this would just allocate space with malloc whenever alloca fails.
This is still a more heavy weight solution than just checking the stack
to see what's available, though.
cgf