1
Fork 0
mirror of https://git.savannah.gnu.org/git/guile.git synced 2025-04-29 19:30:36 +02:00
Commit graph

10 commits

Author SHA1 Message Date
Ludovic Courtès
b8031fc965
Exclude the finalizer thread from the ‘all-threads’ result.
Fixes <https://bugs.gnu.org/76343>.

Fixes a bug whereby “echo '(environ)' | guile” would wrongfully trigger
the multiple-thread warning.

* libguile/finalizers.c (finalizer_thread): New variable.
(finalization_thread_proc): Set it.
(scm_i_is_finalizer_thread): New function.
(run_finalization_thread): Clear FINALIZER_THREAD.
* libguile/finalizers.h (scm_i_is_finalizer_thread): New declaration.
* libguile/threads.c (scm_all_threads): Use it.
* NEWS: Update.

Reported-by: Simon Josefsson <simon@josefsson.org>
2025-02-28 22:12:03 +01:00
Andy Wingo
1234bb1850 Update license notices in all C files
Update to newest recommended license notices from the FSF.  Everything
stays LGPLv3+ except guile-readline which is GPLv3+.
2018-06-20 20:07:34 +02:00
Andy Wingo
c836c28496 libguile header files have uniform format for copyright declarations 2018-06-20 19:44:45 +02:00
Andy Wingo
791eb0c01a Remove (C) from copyright statements
As the FSF advises, 'There is no legal significance to using the
three-character sequence “(C)”, but it does no harm.'  It does take up
space though!  For that reason, we remove it here from our C files.
2018-06-20 19:17:06 +02:00
Andy Wingo
97cc65fee4 Rename __scm.h to scm.h
* libguile/scm.h: Rename.  Update all includers.
2018-06-20 16:33:33 +02:00
Andy Wingo
c9910c6042 Fix finalizer resuscitation causing excessive GC
* libguile/finalizers.c (async_gc_finalizer):
  (scm_i_register_async_gc_callback): Replace "weak gc callback"
  mechanism with "async gc callback" mechanism.  Very similar but the
  new API is designed to be called a bounded number of times, to avoid
  running afoul of libgc heuristics.
* libguile/weak-list.h: New internal header.
* libguile/Makefile.am (noinst_HEADERS): Add weak-list.h.
* libguile/weak-set.c (vacuum_all_weak_sets):
  (scm_c_make_weak_set, scm_init_weak_set):
* libguile/weak-table.c (vacuum_all_weak_tables):
  (scm_c_make_weak_table, scm_init_weak_table): Arrange to vacuum all
  weak sets from a single async GC callback, and likewise for weak
  tables.

Thanks to Ludovic Courtès for tracking this bug down!
2017-03-13 15:47:51 +01:00
Andy Wingo
d6651f6903 Add interface to disable automatic finalization
* libguile/finalizers.h:
* libguile/finalizers.c (run_finalizers_async_thunk)
  (finalization_thread_proc): Call the new scm_run_finalizers helper.
  (scm_i_finalizer_pre_fork): Only spawn the thread if automatic
  finalization is enabled.
  (scm_set_automatic_finalization_enabled, scm_run_finalizers): New
  functions.
  (scm_init_finalizers, scm_init_finalizer_thread): Only set a finalizer
  notifier if automatic finalization is enabled.

* doc/ref/libguile-smobs.texi (Garbage Collecting Smobs): Add discussion
  of concurrency.

* doc/ref/api-smobs.texi (Smobs): Document new functions.
2014-04-17 15:29:13 +02:00
Andy Wingo
a0551390d5 consolidate scm_i_register_weak_gc_callback, update weak-set to fit
* libguile/finalizers.h:
* libguile/finalizers.c (scm_i_register_weak_gc_callback): New internal
  helper, from weak-set.c.

  Relative to the previous weak-set.c version, prefer the
  finalizer-based implementation.  Fix bug regarding confusion between
  scm_before_gc_c_hook and scm_after_gc_hook.  Fix bug regarding
  referencing weak values outside of the alloc lock.

* libguile/weak-set.c (GC_move_disappearing_link): New stub.
  GC_move_disappearing_link is only available in libgc 7.3.
  (move_weak_entry): Use the new stub instead of ifdeffery.
  (resize_set): Now that we run finalizers from a separate thread or
  async, we can keep the lock while reallocating the set vector.
  (do_vacuum_weak_set): For the same reason, always lock the set.
  Remove implementation of scm_c_register_weak_gc_callback in preference
  of the new copy in finalizers.c.
  (scm_c_make_weak_set): Use the new scm_i_register_weak_gc_callback.
2013-01-20 12:37:00 +01:00
Andy Wingo
eaf99988ae run finalizers asynchronously (in asyncs and/or pthreads)
* libguile/finalizers.c: New excitement!  We'll be running finalizers in
  threads, if that's available.  If it's not available, during early
  boot, we can run finalizers in asyncs.  This will make it safer to
  allocate while holding a mutex.

* libguile/posix.c (scm_fork): Shut down the finalizer thread before
  forking.

* libguile/init.c (scm_i_init_guile): Init the async finalizer mechanism
  during boot and, if available, initialialize the finalizer thread at
  the very end.

* libguile/gc.c (scm_storage_prehistory): Tell libgc we'll be finalizing
  on demand.
  (scm_gc): Explicitly run finalizers here.  If you're calling this
  function, you probably want synchronous GC.
2012-02-24 13:33:02 +01:00
Andy Wingo
6e9ec86dc0 add scm_i_set_finalizer, scm_i_add_finalizer, scm_i_add_resuscitator
* libguile/finalizers.h:
* libguile/finalizers.c: New files.

* libguile.h:
* libguile/Makefile.am: Add to build.
2012-02-19 20:46:14 +01:00