[Top][All Lists]

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

[Chicken-users] Chicken + swig + C unions = infinite loop

From: Dave
Subject: [Chicken-users] Chicken + swig + C unions = infinite loop
Date: Wed, 14 May 2003 20:33:48 -0400
User-agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.4b) Gecko/20030507

Chicken looks really promising since I have been looking for something that can wrap C++ apis and let me play around with them in a decent language like scheme. In the course of trying it out by interfacing to SDL , I think I am encountering a problem with C "union" types (SDL_Event is a union of all the event types). I have a small test case below that seems to demonstrate the problem which only seems to occur when allocating unions and manifests as an infinite loop. I assume that it is in the GC cycle, but I'm not sure.
Here are the commands I used:

swig -chicken crash.i
csc crash_wrap.c crash.scm crash_test.scm

in crash_test.scm, the first and second loops complete, but the third
drops into a 100% cpu tailspin and never seems to recover. I tried this with the chicken 1.0 release and the 1.9 development version.

I'd really appreciate any pointers anyone can give me with this!


------------- crash.i --------------------------
%module crash

%inline %{
typedef union {
        int testit;
        int r;
} combo;

------------- crash_test.scm -------------------

(declare (uses crash))

(time (do ((x 0 (+ x 1))) ((> x 10000) x) (crash:delete-combo (crash:new-combo))))
(display "1\n")
(time (do ((x 0 (+ x 1))) ((> x 10000) x) (crash:delete-combo (crash:new-combo))))
(display "2\n")
(time (do ((x 0 (+ x 1))) ((> x 10000) x) (crash:delete-combo (crash:new-combo))))
(display "3\n")

reply via email to

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