summaryrefslogtreecommitdiff
Commit message (Collapse)AuthorAgeFilesLines
* raise ZombieProcess instead of AccessDenied if process is a zombielinux-zombie-procGiampaolo Rodola2022-10-194-3/+44
|
* chore: skip test_cpu_freq on macOS arm64 (#2146)Matthieu Darbois2022-10-184-0/+12
|
* Merge branch 'master' of github.com:giampaolo/psutilGiampaolo Rodola2022-10-181-1/+1
|\
| * Fix a typo (#2047)iam-py-test2022-10-181-1/+1
| |
* | pre-release + give CREDITS to @mayeut (PR #2040) and @eallrich (new supporter)release-5.9.3Giampaolo Rodola2022-10-183-4/+10
|/ | | | Signed-off-by: Giampaolo Rodola <g.rodola@gmail.com>
* move isort and coverage config into pyproject.tomlGiampaolo Rodola2022-10-188-48/+47
| | | | | | ...since pyproject.toml was introduced in #2040. CC @mayeut Signed-off-by: Giampaolo Rodola <g.rodola@gmail.com>
* Merge branch 'master' of github.com:giampaolo/psutilGiampaolo Rodola2022-10-183-27/+18
|\
| * fix #2021, fix #1954, provide OSX arm64 bins + add pyproject.toml (#2040)Matthieu Darbois2022-10-183-27/+18
| | | | | | | | | | | | This commit updates the build workflow to use the latest cibuildwheel as a GitHub Action. cibuildwheel configuration is now in its own file (as there's no `pyproject.toml` yet) Signed-off-by: mayeut <mayeut@users.noreply.github.com>
* | Merge branch 'master' of github.com:giampaolo/psutilGiampaolo Rodola2022-10-109-6/+109
|\ \ | |/
| * fix: race condition in test_posix.TestProcess.test_cmdline (#2153)Matthieu Darbois2022-10-083-1/+9
| |
| * fix: disk usage report on macOS 12+ (#2152)Matthieu Darbois2022-10-058-6/+101
| |
* | Merge branch 'master' of github.com:giampaolo/psutilGiampaolo Rodola2022-10-024-5/+10
|\ \ | |/
| * Resolve race condition in Process.threads() (#2151)Daniel Li2022-09-293-4/+9
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * Resolve race condition in Process.threads() Process.threads() has a race condition triggered when a thread exits after the open_binary() call and before the read() call. When this happens, the read() call raises ProcessLookupError. Handle the race condition by catching ProcessLookupError from read() and treating the same as a FileNotFoundError from open_binary(). This is the same approach used in ppid_map(). Signed-off-by: Daniel Li <daniel.li@deshaw.com> * Also catch ProcessLookupError in open_files() Signed-off-by: Daniel Li <daniel.li@deshaw.com>
| * chore: use macos-12 runner for FreeBSD tests (#2145)Matthieu Darbois2022-09-221-1/+1
| |
* | refactor git_log.pyGiampaolo Rodola2022-09-231-1/+0
|/
* #2084: document limitations of environ() on macOS Big SurGiampaolo Rodola2022-09-205-7/+30
|
* #2104 / TestFetchAllProcesses: don't use process pool on CI (fix deadlock)Giampaolo Rodola2022-09-202-5/+16
|
* fix #2116, macOS, net_connections() crashingGiampaolo Rodola2022-09-192-0/+9
| | | | | | It turns out that proc_pidinfo() crashes for PID 0 Signed-off-by: Giampaolo Rodola <g.rodola@gmail.com>
* fix #2138 (critical): re-define ethtool_cmd_speedGiampaolo Rodola2022-09-192-1/+9
|
* Fix macOS Python 2.7 build (#2140)Ben Raz2022-09-191-3/+3
| | | | | | | | | Currently Python 2.7 tests & builds were run twice for Linux instead. Swap configuration to macOS 10.15, in par with Python 3 workflow, and to make Process.environ tests pass (broken in macOS 11+). Signed-off-by: Ben Raz <ben9923@gmail.com>
* remove fix_flake8.py re-introduced by accidentGiampaolo Rodola2022-09-192-186/+1
| | | | Signed-off-by: Giampaolo Rodola <g.rodola@gmail.com>
* Merge branch 'kianmeng-fix-typos'Giampaolo Rodola2022-09-1922-42/+227
|\
| * resolve conflictsGiampaolo Rodola2022-09-1922-42/+227
| |\ |/ / | | | | Signed-off-by: Giampaolo Rodola <g.rodola@gmail.com>
| * Fix typosKian-Meng Ang2022-01-2728-56/+56
| |
* | [macOS] Fix out-of-bounds read around sysctl_procargs (#2135)Bernhard Urban-Forster2022-09-193-6/+13
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The buffer size is initially determined by querying `argmax`: https://github.com/giampaolo/psutil/blob/9f9a82d02c901f62512236b44edb050f84cbe5b6/psutil/arch/osx/process_info.c#L260-L265 This length is passed to the `sysctl()` call for querying the procargs. `sysctl()` is allowed to set it to a smaller value, to indicate the buffer wasn't fully used. However this is not passed back to the caller "owning" that memory, and also parsing the result. Depending on the allocator, it's possible that we can observe "garbage" values, consider this example: ```python import psutil import subprocess import os import sys environment_cookie = "__MAGIC_ENV_COOKIE__" for i in range(0,200): os.environ["PATH"] = os.environ.get("PATH", "") + os.pathsep + environment_cookie + str(i) print("sys.executable: " + str(sys.executable)) exe = os.path.split(sys.executable)[1] exe = exe.split(".")[0] print("exe: " + str(exe)) polluted_process = subprocess.Popen([exe, "-c", "import time; time.sleep(3)"], env=os.environ.copy()) clean_process = subprocess.Popen([exe, "-c", "import time; time.sleep(3)"], env={}) print("polluted pid=" + str(polluted_process.pid)) print("clean pid=" + str(clean_process.pid)) pp = psutil.Process(polluted_process.pid) pc = psutil.Process(clean_process.pid) for i in range(0,8): pp.environ() for i in range(0,8): e = pc.environ() if len(e) > 0: print("clean subprocess (should be empty) env=" + str(e)) exit(2) print("no repro, try again :-/") ``` In order to better illustrate the problem, I added this debug output to `psutils`: ```diff +++ psutil/arch/osx/process_info.c @@ -263,6 +263,7 @@ psutil_get_environ(pid_t pid) { goto error; procargs = (char *)malloc(argmax); + printf("[psutil_get_environ] pid=%d, procargs=%p\n", pid, procargs); if (NULL == procargs) { PyErr_NoMemory(); goto error; ``` Example output: ``` $ python3 .py sys.executable: /opt/homebrew/opt/python@3.10/bin/python3.10 exe: python3 polluted pid=63479 clean pid=63480 [psutil_get_environ] pid=63479, procargs=0x140088000 [psutil_get_environ] pid=63479, procargs=0x140188000 [psutil_get_environ] pid=63479, procargs=0x140088000 [psutil_get_environ] pid=63479, procargs=0x140188000 [psutil_get_environ] pid=63479, procargs=0x140088000 [psutil_get_environ] pid=63479, procargs=0x140188000 [psutil_get_environ] pid=63479, procargs=0x140088000 [psutil_get_environ] pid=63479, procargs=0x140188000 [psutil_get_environ] pid=63480, procargs=0x140088000 clean subprocess (should be empty) env={'EDITOR': 'vim', [[removed]], 'PATH': '/opt/homebrew/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:__MAGIC_ENV_COOKIE__0:__MAGIC_ENV_COOKIE__1:__MAGIC_ENV_COOKIE__2:__MAGIC_ENV_COOKIE__3:__MAGIC_ENV_COOKIE__4:__MAGIC_ENV_COOKIE__5:__MAGIC_ENV_COOKIE__6:__MAGIC_ENV_COOKIE__7:__MAGIC_ENV_COOKIE__8:__MAGIC_ENV_COOKIE__9:__MAGIC_ENV_COOKIE__10:__MAGIC_ENV_COOKIE__11:__MAGIC_ENV_COOKIE__12:__MAGIC_ENV_COOKIE__13:__MAGIC_ENV_COOKIE__14:__MAGIC_ENV_COOKIE__15:__MAGIC_ENV_COOKIE__16:__MAGIC_ENV_COOKIE__17:__MAGIC_ENV_COOKIE__18:__MAGIC_ENV_COOKIE__19:__MAGIC_ENV_COOKIE__20:__MAGIC_ENV_COOKIE__21:__MAGIC_ENV_COOKIE__22:__MAGIC_ENV_COOKIE__23:__MAGIC_ENV_COOKIE__24:__MAGIC_ENV_COOKIE__25:__MAGIC_ENV_COOKIE__26:__MAGIC_ENV_COOKIE__27:__MAGIC_ENV_COOKIE__28:__MAGIC_ENV_COOKIE__29:__MAGIC_ENV_COOKIE__30:__MAGIC_ENV_COOKIE__31:__MAGIC_ENV_COOKIE__32:__MAGIC_ENV_COOKIE__33:__MAGIC_ENV_COOKIE__34:__MAGIC_ENV_COOKIE__35:__MAGIC_ENV_COOKIE__36:__MAGIC_ENV_COOKIE__37:__MAGIC_ENV_COOKIE__38:__MAGIC_ENV_COOKIE__39:__MAGIC_ENV_COOKIE__40:__MAGIC_ENV_COOKIE__41:__MAGIC_ENV_COOKIE__42:__MAGIC_ENV_COOKIE__43:__MAGIC_ENV_COOKIE__44:__MAGIC_ENV_COOKIE__45:__MAGIC_ENV_COOKIE__46:__MAGIC_ENV_COOKIE__47:__MAGIC_ENV_COOKIE__48:__MAGIC_ENV_COOKIE__49:__MAGIC_ENV_COOKIE__50:__MAGIC_ENV_COOKIE__51:__MAGIC_ENV_COOKIE__52:__MAGIC_ENV_COOKIE__53:__MAGIC_ENV_COOKIE__54:__MAGIC_ENV_COOKIE__55:__MAGIC_ENV_COOKIE__56:__MAGIC_ENV_COOKIE__57:__MAGIC_ENV_COOKIE__58:__MAGIC_ENV_COOKIE__59:__MAGIC_ENV_COOKIE__60:__MAGIC_ENV_COOKIE__61:__MAGIC_ENV_COOKIE__62:__MAGIC_ENV_COOKIE__63:__MAGIC_ENV_COOKIE__64:__MAGIC_ENV_COOKIE__65:__MAGIC_ENV_COOKIE__66:__MAGIC_ENV_COOKIE__67:__MAGIC_ENV_COOKIE__68:__MAGIC_ENV_COOKIE__69:__MAGIC_ENV_COOKIE__70:__MAGIC_ENV_COOKIE__71:__MAGIC_ENV_COOKIE__72:__MAGIC_ENV_COOKIE__73:__MAGIC_ENV_COOKIE__74:__MAGIC_ENV_COOKIE__75:__MAGIC_ENV_COOKIE__76:__MAGIC_ENV_COOKIE__77:__MAGIC_ENV_COOKIE__78:__MAGIC_ENV_COOKIE__79:__MAGIC_ENV_COOKIE__80:__MAGIC_ENV_COOKIE__81:__MAGIC_ENV_COOKIE__82:__MAGIC_ENV_COOKIE__83:__MAGIC_ENV_COOKIE__84:__MAGIC_ENV_COOKIE__85:__MAGIC_ENV_COOKIE__86:__MAGIC_ENV_COOKIE__87:__MAGIC_ENV_COOKIE__88:__MAGIC_ENV_COOKIE__89:__MAGIC_ENV_COOKIE__90:__MAGIC_ENV_COOKIE__91:__MAGIC_ENV_COOKIE__92:__MAGIC_ENV_COOKIE__93:__MAGIC_ENV_COOKIE__94:__MAGIC_ENV_COOKIE__95:__MAGIC_ENV_COOKIE__96:__MAGIC_ENV_COOKIE__97:__MAGIC_ENV_COOKIE__98:__MAGIC_ENV_COOKIE__99:__MAGIC_ENV_COOKIE__100:__MAGIC_ENV_COOKIE__101:__MAGIC_ENV_COOKIE__102:__MAGIC_ENV_COOKIE__103:__MAGIC_ENV_COOKIE__104:__MAGIC_ENV_COOKIE__105:__MAGIC_ENV_COOKIE__106:__MAGIC_ENV_COOKIE__107:__MAGIC_ENV_COOKIE__108:__MAGIC_ENV_COOKIE__109:__MAGIC_ENV_COOKIE__110:__MAGIC_ENV_COOKIE__111:__MAGIC_ENV_COOKIE__112:__MAGIC_ENV_COOKIE__113:__MAGIC_ENV_COOKIE__114:__MAGIC_ENV_COOKIE__115:__MAGIC_ENV_COOKIE__116:__MAGIC_ENV_COOKIE__117:__MAGIC_ENV_COOKIE__118:__MAGIC_ENV_COOKIE__119:__MAGIC_ENV_COOKIE__120:__MAGIC_ENV_COOKIE__121:__MAGIC_ENV_COOKIE__122:__MAGIC_ENV_COOKIE__123:__MAGIC_ENV_COOKIE__124:__MAGIC_ENV_COOKIE__125:__MAGIC_ENV_COOKIE__126:__MAGIC_ENV_COOKIE__127:__MAGIC_ENV_COOKIE__128:__MAGIC_ENV_COOKIE__129:__MAGIC_ENV_COOKIE__130:__MAGIC_ENV_COOKIE__131:__MAGIC_ENV_COOKIE__132:__MAGIC_ENV_COOKIE__133:__MAGIC_ENV_COOKIE__134:__MAGIC_ENV_COOKIE__135:__MAGIC_ENV_COOKIE__136:__MAGIC_ENV_COOKIE__137:__MAGIC_ENV_COOKIE__138:__MAGIC_ENV_COOKIE__139:__MAGIC_ENV_COOKIE__140:__MAGIC_ENV_COOKIE__141:__MAGIC_ENV_COOKIE__142:__MAGIC_ENV_COOKIE__143:__MAGIC_ENV_COOKIE__144:__MAGIC_ENV_COOKIE__145:__MAGIC_ENV_COOKIE__146:__MAGIC_ENV_COOKIE__147:__MAGIC_ENV_COOKIE__148:__MAGIC_ENV_COOKIE__149:__MAGIC_ENV_COOKIE__150:__MAGIC_ENV_COOKIE__151:__MAGIC_ENV_COOKIE__152:__MAGIC_ENV_COOKIE__153:__MAGIC_ENV_COOKIE__154:__MAGIC_ENV_COOKIE__155:__MAGIC_ENV_COOKIE__156:__MAGIC_ENV_COOKIE__157:__MAGIC_ENV_COOKIE__158:__MAGIC_ENV_COOKIE__159:__MAGIC_ENV_COOKIE__160:__MAGIC_ENV_COOKIE__161:__MAGIC_ENV_COOKIE__162:__MAGIC_ENV_COOKIE__163:__MAGIC_ENV_COOKIE__164:__MAGIC_ENV_COOKIE__165:__MAGIC_ENV_COOKIE__166:__MAGIC_ENV_COOKIE__167:__MAGIC_ENV_COOKIE__168:__MAGIC_ENV_COOKIE__169:__MAGIC_ENV_COOKIE__170:__MAGIC_ENV_COOKIE__171:__MAGIC_ENV_COOKIE__172:__MAGIC_ENV_COOKIE__173:__MAGIC_ENV_COOKIE__174:__MAGIC_ENV_COOKIE__175:__MAGIC_ENV_COOKIE__176:__MAGIC_ENV_COOKIE__177:__MAGIC_ENV_COOKIE__178:__MAGIC_ENV_COOKIE__179:__MAGIC_ENV_COOKIE__180:__MAGIC_ENV_COOKIE__181:__MAGIC_ENV_COOKIE__182:__MAGIC_ENV_COOKIE__183:__MAGIC_ENV_COOKIE__184:__MAGIC_ENV_COOKIE__185:__MAGIC_ENV_COOKIE__186:__MAGIC_ENV_COOKIE__187:__MAGIC_ENV_COOKIE__188:__MAGIC_ENV_COOKIE__189:__MAGIC_ENV_COOKIE__190:__MAGIC_ENV_COOKIE__191:__MAGIC_ENV_COOKIE__192:__MAGIC_ENV_COOKIE__193:__MAGIC_ENV_COOKIE__194:__MAGIC_ENV_COOKIE__195:__MAGIC_ENV_COOKIE__196:__MAGIC_ENV_COOKIE__197:__MAGIC_ENV_COOKIE__198:__MAGIC_ENV_COOKIE__199'} ``` As you can see the allocated buffer for `pid=63480` matches with some instances of `pid=63479`. Kudos to @naoufal450 and @gilles-duboscq for debugging this issue! Signed-off-by: Bernhard Urban-Forster <bernhard.urban-forster@oracle.com> Signed-off-by: Bernhard Urban-Forster <bernhard.urban-forster@oracle.com> Co-authored-by: Giampaolo Rodola <g.rodola@gmail.com>
* | Set parsable BSD-3-Clause license in setup.py (#2141)Maximilian2022-09-191-1/+1
| |
* | update version + HISTORY + CREDITS for #2138Giampaolo Rodola2022-09-193-2/+12
| |
* | net_if_stats() -> flags: do not return unicode on Python 2 (#2142)Matthieu Darbois2022-09-192-1/+14
| | | | | | | | | | | | Do not use unicode string for network interface flags on Python 2 Update network interface flags tests to work on CentOS 6 (CI tests are currently failing) Signed-off-by: mayeut <mayeut@users.noreply.github.com>
* | Use recommended (more-updated) freebsd-vm version (#2139)Ben Raz2022-09-151-1/+1
| |
* | add ifconfig test case for NIC flags re. to #2037Giampaolo Rodola2022-09-062-1/+22
| |
* | Add in support for network interface flags. (#2037)Chris Lalancette2022-09-0613-16/+246
| | | | | | | | Signed-off-by: Chris Lalancette <clalancette@openrobotics.org>
* | fix venvrelease-5.9.2Giampaolo Rodola2022-09-043-14/+13
| |
* | update HISTORY + bump up versionGiampaolo Rodola2022-09-022-8/+13
| |
* | FreeBSD / pids(): increase buf size if not enoughGiampaolo Rodola2022-09-023-14/+34
| | | | | | | | | | ...dynamically, in case of ENOMEM, instead of crashing. Fixes #2093.
* | [NetBSD] get data about cached memory usage from /proc/meminfo as well (#2088)Thomas Klausner2022-08-271-0/+2
| |
* | fix sphinx warning: unexpected unindent (#2118)Xuehai Pan2022-08-181-1/+1
| |
* | [NetBSD] two fixes for swap code (#2128)Thomas Klausner2022-08-183-4/+5
| |
* | Fix missing whitespace in try-except caluses (#2127)Ben Raz2022-07-311-2/+2
| |
* | linux: skip test if ifconfig CLI is not installedGiampaolo Rodola2022-07-261-0/+2
| |
* | Merge branch 'master' of github.com:giampaolo/psutilGiampaolo Rodola2022-07-263-2/+13
|\ \
| * | docs: fix simple typo, repeadetly -> repeatedly (#2123)Tim Gates2022-07-141-1/+1
| | |
| * | [Linux] `net_if_stats()` returns an incorrect speed value for 100GbE network ↵garrisoncarter2022-07-112-1/+12
| | | | | | | | | | | | cards (#2096)
* | | subprocess; avoid using shell=True during testsGiampaolo Rodola2022-07-101-3/+4
| | |
* | | remove 'import setuptools' from 'make install' as it's unnecessary and slowGiampaolo Rodola2022-07-071-2/+0
| | |
* | | refactor Makefile a bitGiampaolo Rodola2022-07-051-5/+4
|/ / | | | | | | Signed-off-by: Giampaolo Rodola <g.rodola@gmail.com>
* | Merge branch 'master' of github.com:giampaolo/psutilGiampaolo Rodola2022-06-245-0/+11
|\ \
| * | Implicitly include <sys/param.h> so that __FreeBSD_version checks wor… (#2114)Torsten-B2022-06-245-0/+11
| | |
* | | make fix-flake8: parallelize autoflake8 executionGiampaolo Rodola2022-06-241-2/+2
| | | | | | | | | | | | | | | | | | | | | ...by pip-installing a PR I provided for autoflake8 packages which adds --jobs option to the tool, see https://github.com/PyCQA/autoflake/pull/107 Signed-off-by: Giampaolo Rodola <g.rodola@gmail.com>
* | | Merge branch 'master' of github.com:giampaolo/psutilGiampaolo Rodola2022-06-142-2/+5
|\ \ \ | |/ /
| * | Fix AppVeyor CI (#2111)Matthieu Darbois2022-06-052-2/+5
| | |