This is the mail archive of the mailing list for the guile project.

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Re: Calling Scheme from C and Garbage Collection

>Several years ago, before
>Guile, a Cray Research compiler upgrade did break my port of SCM --
>it was necessary to write a replacement for setjmp in order to make
>SCM garbage collection work.
>The problem is variables being optimized away entirely, not merely
>allocated in registers.  Guile assumes that SCM objects passed on
>the C stack are protected -- this is not necessarily true for C
>compilers that do aggressive inlining.  It was necessary to turn
>off inlining in the case of the Cray port.
>To sum up, conservative gc requires a chumminess with the C compiler
>that is not warranted by any standard.  It may require platform and
compiler >specific hacks in order to work properly.

After reading the various responses to this issue, I'm a bit confused about
whether this problem is real or not, but it sounds worrying. I'll be living
in fear of better C compilers. Potentially, a seemingly innocent change to
your C code could trigger some compiler optimisation to kick in, or else
previous working code could be trashed by a future compiler upgrade that is
smarter at removing variables. And how would you know? Your program crashes
at random times - maybe once a day/week/year, but you'd never find the
problem. Code walkthroughs would tell you nothing.

>I have actually tried your exhaustive testing solution -- it is *far*
>too slow to be practical.

I don't think it's too slow if you just want to do unit testing of a number
new functions, satisfy yourself, and then switch it off again.