Issue 675259: os.environ leaks under FreeBSD and Mac OS X (original) (raw)

Issue675259

Created on 2003-01-27 05:39 by zenzen, last changed 2022-04-10 16:06 by admin. This issue is now closed.

Messages (5)
msg14221 - (view) Author: Stuart Bishop (zenzen) Date: 2003-01-27 05:39
If this sort if thing is documented anywhere, the putenv(3) method leaks under FreeBSD and Mac OS X (Mac OS X documents it as a bug they inherited from the FreeBSD codebase in the man page). So don't set environment variables in a loop.
msg14222 - (view) Author: Stuart Bishop (zenzen) Date: 2003-01-29 00:15
Logged In: YES user_id=46639 Relevant URL's: http://www.freebsd.org/cgi/query-pr.cgi?pr=misc/19406 http://www.freebsd.org/cgi/query-pr.cgi?pr=10341 http://www.freebsd.org/cgi/query-pr.cgi?pr=5604 An alternative may be to bypass the putenv(3) method on these platforms and manipulate environ manually in which case this is not a documentation bug but a feature request.
msg14223 - (view) Author: Neal Norwitz (nnorwitz) * (Python committer) Date: 2003-02-07 01:28
Logged In: YES user_id=33168 Stuart have you tested this or are you just assuming that putenv leaks in python? I tested this on FreeBSD and the process did not leak. Note that python maintains a dictionary of all the values set with putenv, if they are set again, the memory will be cleared. See posix_putenv() in posixmodule.c and the posix_putenv_garbage variable.
msg14224 - (view) Author: Stuart Bishop (zenzen) Date: 2003-02-07 01:45
Logged In: YES user_id=46639 The following code will demonstrate the issue under Mac OS X (measured using 'top'). I havn't got access to a FreeBSD system to test it on. Python 2.3a1 (#1, Jan 30 2003, 16:43:39) [GCC 3.1 20020420 (prerelease)] on darwin Type "help", "copyright", "credits" or "license" for more information. >>> import os >>> while 1: ... for e in ['some','strings','of','different','length']: ... os.environ['TZ'] = e ... del os.environ['TZ'] ... Removing the 'del os.environ['TZ'] line makes no difference.
msg14225 - (view) Author: Neal Norwitz (nnorwitz) * (Python committer) Date: 2003-02-07 02:35
Logged In: YES user_id=33168 Ok, I tried simpler code on FreeBSD 4.7 and expected to see the leak. Thanks. Checked in Doc/lib/libos.tex 1.111 and 1.74.2.1.2.10
History
Date User Action Args
2022-04-10 16:06:11 admin set github: 37839
2003-01-27 05:39:16 zenzen create