[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: lua_resume and a C-function as the main coroutine function problem
- From: Tony Finch <dot@...>
- Date: Wed, 14 Apr 2010 16:09:15 +0100
On Wed, 14 Apr 2010, David Given wrote:
> On 2010-04-14 14:34, Tony Finch wrote:
> [...]
> > vois *osp =&f;
> > void *nsp = malloc(STACKSIZE) + STACKSIZE - SLOP;
> > void *dummy = alloca(osp - nsp);
>
> I would be very, very careful doing things like this --- you're utterly at
> mercy of the implementation. This will, for example, trigger any stack limit
> checking that your toolchain might be doing. And woe betide you if your
> alloca() implementations tries to memset() the data!
Yes :-)
If your implementation strays from traditional Unix (e.g. HP/UX) your
program will crash. But I think it's quite a good joke, and fun for
bending brains.
Tony.
--
f.anthony.n.finch <dot@dotat.at> http://dotat.at/
GERMAN BIGHT HUMBER: SOUTHWEST 5 TO 7. MODERATE OR ROUGH. SQUALLY SHOWERS.
MODERATE OR GOOD.