|
From: | Valentyn Kamyshenko |
Subject: | Re: [Chicken-users] a couple of questions about foreign functions |
Date: | Thu, 22 Jan 2004 00:38:06 -0800 |
On Jan 22, 2004, at 12:02 AM, Felix Winkelmann wrote:
Am Wed, 21 Jan 2004 23:52:38 -0800 hat Valentyn Kamyshenko <address@hidden> geschrieben:When this function returns, `buf' will point into a dead stack area, so the data is likely to be corrupted after the return.I suspected it!.What makes the following code correct, then (have found it in runtime.c):[...]it looks like the vector is created on the stack, and then 'returned' to the continuation...Indeed. But the invocation of the continuation (via `C_kontinue') does *never* return, the data will remain on the stack and be collectedwhen a certain stack-limit is reached. C-code wrapped with ##core#primitiveinvokes it's continuation (and thus the stack is not popped), but codewrapped with foreign-[callback-]lambda will return normally, in C fashion.
finally, I got it.I had an impression that foreign-lambda never returns (that is, that it behaves the same way as ##core#primitive). I'd suggest to add a line to the documentation that makes it clear.
Thank you! Yet another question.Do I understand correctly, that for proper signal handling (in unix) the main branch should explicitly pass control to the scheduler? That is, e.g., if I use a library that uses (blocking) select or accept, the signals will be queued until the select (or accept) returns?
Is there a workaround? Thanks, Valentyn.
[Prev in Thread] | Current Thread | [Next in Thread] |