diff -U4 -r guile-2.0.9/libguile/threads.c guile-2.0.9-new/libguile/threads.c --- guile-2.0.9/libguile/threads.c Mon Mar 18 23:30:13 2013 +++ guile-2.0.9-new/libguile/threads.c Mon Jun 17 11:03:04 2013 @@ -325,12 +325,22 @@ for (p = SCM_CDR (q); !scm_is_null (p); p = SCM_CDR (p)) { if (scm_is_eq (p, c)) { - if (scm_is_eq (c, SCM_CAR (q))) - SCM_SETCAR (q, SCM_CDR (c)); + /* Remove c from the list */ SCM_SETCDR (prev, SCM_CDR (c)); + /* If c is the last entry in the list, + then update the (car q) to be the new last entry. + Check whether the q is now empty. */ + if (scm_is_eq (c, SCM_CAR (q))) + { + if (scm_is_null (SCM_CDR (q))) + SCM_SETCAR (q, SCM_EOL); + else + SCM_SETCAR (q, prev); + } + /* GC-robust */ SCM_SETCDR (c, SCM_EOL); SCM_CRITICAL_SECTION_END;