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

Warn about mutation of ‘environ’ when multi-threaded.

This is an amendment to 84bf840322.

The warning was only emitted for calling `environ', even if only reading
and no mutation occurred.

However, it is correct to read the environment in a multi-threaded
process.  It is however unsafe to mutate it.

The same logic also applies to `putenv'.

* libguile/posix.c
  (maybe_warn_about_environ_mutation): New private procedure ...
  (scm_environ): ... called here when mutating the environment ...
  (scm_putenv): ... and here.
* NEWS: Update.

Signed-off-by: Ludovic Courtès <ludo@gnu.org>
This commit is contained in:
Olivier Dion 2025-02-18 20:40:41 -05:00 committed by Ludovic Courtès
parent b8031fc965
commit 7b7340b2d9
No known key found for this signature in database
GPG key ID: 090B11993D9AEBB5
2 changed files with 21 additions and 12 deletions

2
NEWS
View file

@ -86,6 +86,8 @@ every line in a file.
in turn, would trigger warnings from 'primitive-fork' and 'environ'
suggesting they are being called in a multi-threaded context, when in
fact user code did not create any thread.
** Calling 'environ' without arguments in a multi-threaded program is OK
This used to trigger a warning, unduly.
Changes in 3.0.10 (since 3.0.9)