diff --git a/docs/reference/gmodule/modules.md b/docs/reference/gmodule/modules.md index 8f0eeeb4a..1e69918c5 100644 --- a/docs/reference/gmodule/modules.md +++ b/docs/reference/gmodule/modules.md @@ -7,6 +7,9 @@ These functions provide a portable way to dynamically load object files systems that provide an implementation of `dlopen()` (e.g. Linux/Sun), as well as Windows platforms via DLLs. +Do not call these functions from within global constructors (for example, those +using GCC’s `__attribute__((constructor))` attribute) as this may lead to deadlock. + A program which wants to use these functions must be linked to the libraries output by the command: diff --git a/gmodule/gmodule.c b/gmodule/gmodule.c index 8bdcd9da0..26180f878 100644 --- a/gmodule/gmodule.c +++ b/gmodule/gmodule.c @@ -59,6 +59,10 @@ * The #GModule struct is an opaque data structure to represent a * [dynamically-loaded module](modules.html#dynamic-loading-of-modules). * It should only be accessed via the following functions. + * + * To ensure correct lock ordering, these functions must not be called from + * global constructors (for example, those using GCC’s + * `__attribute__((constructor))` attribute). */ /**