Skip to content

genviron: Message if g_setenv()/g_unsetenv() are used after threads spawned

Philip Withnall requested to merge pwithnall/glib:715-setenv-warnings into master

g_setenv() and g_unsetenv() can never be thread-safe, so emit a message if they are used after any threads have been spawned.

This can’t catch interactions between setenv() and g_thread_new(), or between g_setenv() and pthread_create(), but it’ll catch most misbehaviour in GLib-centric code.

Currently, the message is a g_debug() call. Eventually, I’d like to upgrade it to a g_warning(), but there are a number of GLib tests which call g_setenv() after threads have been created, and they need to be fixed first. Emitting a g_debug() message gives people an opportunity to start fixing their code.

Signed-off-by: Philip Withnall withnall@endlessm.com

Helps: #715

Merge request reports