Mark H Weaver <m...@netris.org> writes: > The problem turns out to be that binary ports are not initialized until > the (ice-9 binary-ports) module is loaded. As a result, the port > returned by 'scm_open_bytevector_input_port' has a bad type tag. > > The workaround is to call scm_c_resolve_module ("ice-9 binary-ports") > after initializing Guile before the first call to > 'scm_open_bytevector_input_port'.
It kind of defeats the point of having scm_open_bytevector_input_port in the C library part if you have to call scm_c_resolve_module before use. It's also a rather inscrutable error symptom. Any chance wrong-type-arg can guard against uninitialized/invalid types specifically? There is a reasonably high chance that bad/uninitialized SCM will wash up there. The more thorough way would be to check the type tag to be in valid range before doing any smob callback. -- David Kastrup