tinycc-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Tinycc-devel] Problem using alloca


From: Thomas Preud'homme
Subject: Re: [Tinycc-devel] Problem using alloca
Date: Mon, 30 Jun 2014 22:44:40 +0800
User-agent: KMail/4.12.4 (Linux/3.14-1-amd64; KDE/4.13.1; x86_64; ; )

Le dimanche 29 juin 2014, 21:38:33 Carlos Montiers a écrit :
> Hello.
> I requesting memory from the stack using the function alloca.
> I know that the use of it is discourage, but I want use it anyways.
> 
> I write a code for windows that use it and I tested ok, but only when I
> compile with gcc. Compiling it with tiny c fails, the program crash.
> Maybe is a bug of tiny c.

I assume that your program is compiled on Windows 64 bits, given the alloca 
(INT_MAX). The definition of alloca for Windows 64 bits is in 
lib/alloca86_64.S. When the parameter is bigger than 4096, then it will do a 
loop that allocates 4096 bytes on the stack, read a value on the stack and 
start all over again until all the space asked is allocated. I suppose that 
the goal of the read is to make Windows actually allocate the space to avoid 
an error if a big alloca is made.

I don't know for Windows but on Linux nothing is allocated as long as nothing 
is written. So a big alloca would do nothing and then writing a bit structure 
on the stack would fail as it would make the stack grow too quickly. I guess 
that's what is happening here. Try to reduce the amount given to alloca (Try 
8192 for instance).

Best regards,

Thomas

Attachment: signature.asc
Description: This is a digitally signed message part.


reply via email to

[Prev in Thread] Current Thread [Next in Thread]