[Nix-dev] nix killed by 11

Nicolas Pierron nicolas.b.pierron at gmail.com
Fri Sep 11 11:23:22 CEST 2009


Hi Marc,

On Fri, Sep 11, 2009 at 00:46, Marc Weber <marco-oweber at gmx.de> wrote:
> So does this look like a bug in aterm? If so how to proceed? Is there an
> upstream version I should try first?

If we start hitting ATerm, I want to add my touch ...  The ATerm
library does introspection into the stack to infer possible Terms,
which means if you have a Term stored in the stack, then it would not
be garbage collected.  When you want to have a term stored in the
Heap, location where terms will be stored have to be protected with
ATprotect or ATprotectArray, which are adding a new element in a
linked list.  When a term is created the garbage collector is
"sometimes ?" called to do a lookup of all terms and remove dead
terms.

Nix is a pure language and use a system to make it reentrant, thus all
inputs & outputs of EvalExpr are saved inside an ATermMap which is a
hash-table protected with ATprotectArray.  Therefore, the ATerm
library almost never have to garbage collect terms except if they do
not pass through the EvalExpr function.

So we should try to get rid of the stack introspection because:
- It can makes errors and can alter non-Terms pointers. (already
experience that in a Stratego extension)
- It is not portable to some CPU architecture: those which are saving
stack frames inside registers (and not accessible from deepest stack
frame)

Our usage of the ATerm library can be limited to a "man" commanded
garbage collecting which is limited to protected area because any
garbage collection made during the evaluation is inefficient,  error
prone and time consuming.

-- 
Nicolas Pierron
http://www.linkedin.com/in/nicolasbpierron
Andrew S. Tanenbaum - Never underestimate the bandwith of a wagon full of tapes.



More information about the nix-dev mailing list