[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
bug#31878: Module autoloading is not thread safe
From: |
Ludovic Courtès |
Subject: |
bug#31878: Module autoloading is not thread safe |
Date: |
Thu, 23 Aug 2018 15:54:00 +0200 |
User-agent: |
Gnus/5.13 (Gnus v5.13) Emacs/26.1 (gnu/linux) |
Mark H Weaver <address@hidden> skribis:
> I forgot to mention an important aspect of the proposed auto-load
> locking here. It would not be a global lock, but rather a lock specific
> to the module being loaded. So, I guess we would need a global table of
> locks for modules-being-loaded.
Right (we can’t add a mutex to the module record without breaking the
ABI.)
> Since Guile (unfortunately) allows cyclic module dependencies, we would
> need a mechanism to avoid deadlocks in case modules A and B both import
> each other, and two threads concurrently attempt to load those modules.
>
> The first idea that comes to mind is to also have a global structure
> storing a partial order on the modules currently being loaded. If,
> while module A is being loaded, there's an attempt to auto-load module
> B, then an entry (A < B) would added to the partial order. The partial
> order would not allow cycles to be introduced, reporting an error in
> that case. In case a cycle would be introduced when adding (A < B),
> then the thread would simply be given access to the partially-loaded
> module B, by adding B to its local list of modules-being-loaded.
Would it enough to (1) use recursive mutexes, and (2) have
‘resolve-module’ lookup modules first in the global name space, and
second in the local list of modules being loaded?
Thanks,
Ludo’.