chicken-users
[Top][All Lists]
Advanced

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

Re: [Chicken-users] Segfault when trying to embed Scheme code (4.2.0)


From: John Cowan
Subject: Re: [Chicken-users] Segfault when trying to embed Scheme code (4.2.0)
Date: Tue, 27 Oct 2009 13:20:56 -0400
User-agent: Mutt/1.5.13 (2006-08-11)

Jeronimo Pellegrini scripsit:

> define-external cannot be used for recursive definitions (probably
> supposed to be used only for wrappers -- is this correct?)
> My recursive define-external functions segfaulted; non-recursive
> ones didn't.

The real issue isn't recursion, it's stack consumption.  C recursion
consumes stack, and when Chicken calls C only a small amount of stack
is guaranteed to be available, because of the way Scheme code uses the C
stack (steadily consuming it and then dropping almost all of it at each
minor GC).

If you want, you can call (gc #f) to force a minor collection before
calling your C routine, but of course that takes time.  You also need to
be careful of concurrency: if multiple threads are trying to play that
game, they are very likely to collide, since all Chicken threads share
the C stack.

-- 
John Cowan  <address@hidden>  http://ccil.org/~cowan
Micropayment advocates mistakenly believe that efficient allocation of
resources is the purpose of markets.  Efficiency is a byproduct of market
systems, not their goal.  The reasons markets work are not because users
have embraced efficiency but because markets are the best place to allow
users to maximize their preferences, and very often their preferences are
not for conservation of cheap resources.  --Clay Shirkey




reply via email to

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