[Top][All Lists]

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

Is my procedure getting GCed?

From: Brett Viren
Subject: Is my procedure getting GCed?
Date: Tue, 1 May 2001 12:45:38 -0400 (EDT)

Hi all,

I am (still) working on this GTK-- + Guile (v1.4) application about
which I have asked questions before.  My current problem is I think
the GC is killing stuff out from under me.

The program has a C++ class which stores a Guile procedure as an SCM
which it gets at construction:

    class ScalarBC {
        // ...
        SCM fProc;
    // ...
    ScalarBC my_sbc(gh_eval_str("(lambda () (random:uniform))"));

In response to SIGUSR2 signals, which come about 1/sec, the code
breaks out of GTK--'s main loop and, among other things, calls the
saved procedure in the following method:

void ScalarBC::Update(void)
    // scm_gc();
    if (!gh_procedure_p(fProc)) {
        cerr << "ScalarBC::Update: Have no procedure with which to update\n";
    SCM result = gh_call0(fProc);
    if (!gh_number_p(result)) {
        cerr << "ScalarBC::Update: Procedure doesn't return number\n";

    double x = gh_scm2double(result);

The problem is that after about 100 itterations `my_proc' is no longer
a procedure according to `gh_procedure_p()'.  The exact number of
iterations depends on how many such functions I have.

But, more telling, if I uncomment the `scm_gc()' call, then I
immediately fail the `gh_procedure_p()' check.

Am I doing something wrong here?  Maybe it is not okay to copy SCM
values around?

Is there a way to force Guile not to GC this procedure?

Thanks for any insights,

reply via email to

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