The foreign function pointer returned by "procedure->pointer" can only executed in a thread which Scheme context is already initialized. This may not so convenient because foreign library may create its own thread and run our callback in foreign thread. To show what will happen, this is a small example using Guile FFI & pthread API to create a foreign thread and run foreign callback in it. ``` (begin (use-modules (rnrs bytevectors) (system foreign) (system foreign-library)) (define libc (load-foreign-library #f)) (define pthread_create (foreign-library-function libc "pthread_create" #:return-type int #:arg-types `(* * * *))) (define pthread-handle-ret (make-bytevector 4)) (define thread-runner (procedure->pointer '* (lambda (_) (display "I' m from a foreign thread!\n") %null-pointer) `(*))) (pthread_create (bytevector->pointer pthread-handle-ret) %null-pointer thread-runner %null-pointer)) ``` In Guile 3.0.8. This will cause segfault and crash. My patch to fix this problem is attached below. It wraps the real execution of foreign callback in "scm_with_guile".