> Can you spot some way in which what you are doing > is different to this?
I believe this is a GC problem; you're doing exactly what I'm doing, but in a context where the GC is not called. If I place the skip comment function in its own file, and compile it with optimization turned off, everything is happy; if optimization is on (either -O or -O2), it dies. According to valgrind the problem is in scm_getc -- the SCM_PTAB_ENTRY pointer "pt" does not point to a valid structure, so the read and subsuequent write through pt goes off into unallocated memory. I haven't tracked down the actual problem yet, but gc-protecting the "port" variable does no good.