stack overflow bug in ofstream::operator<<

Corinna Vinschen corinna-cygwin@cygwin.com
Thu Jun 30 13:56:00 GMT 2005


On Jun 30 15:54, Corinna Vinschen wrote:
> Ok.  I take it then that you don't like the way I solved it.  Implementing
> some alloca like function with exception handling is certainly more i386
> assembler than I understand.

Well, my solution would work as a replacement, too:

#define ALLOCA(siz)     \
        ({ \
          extern unsigned long _size_of_stack_reserve__; \
          register char *_curstack __asm__ ("%esp"); \
          size_t size = (siz); \
          ((size_t) ((_curstack - (_tlsbase \
                                   - (size_t) &_size_of_stack_reserve__) \
                    ) / 65536) * 65536 > size) ? alloca (size) : NULL;\
        })


Corinna

-- 
Corinna Vinschen                  Please, send mails regarding Cygwin to
Cygwin Project Co-Leader          mailto:cygwin@cygwin.com
Red Hat, Inc.



More information about the Cygwin-developers mailing list