Date: Sat, 08 Aug 2020 14:41:40 +0000 From: bugzilla-noreply@freebsd.org To: bugs@FreeBSD.org Subject: [Bug 248537] procstat -e/kvm_getenvv() fails for specific processes Message-ID: <bug-248537-227@https.bugs.freebsd.org/bugzilla/>
next in thread | raw e-mail | index | archive | help
https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=3D248537 Bug ID: 248537 Summary: procstat -e/kvm_getenvv() fails for specific processes Product: Base System Version: 12.1-RELEASE Hardware: Any OS: Any Status: New Severity: Affects Some People Priority: --- Component: kern Assignee: bugs@FreeBSD.org Reporter: ag-freebsd@muc.de While implementing *BSD platform support for sysutils/py-psutils, I've encountered strange behaviour when using either the libprocstat or kvm interface to retrieve the environ for a foreign process on the system: Both kvm_getenvv() and procstat_getenvv() return ENOMEM on some systems. This happens repeatingly reproducable e.g. for the X11 Xorg server process;= it can already be seen by using system utilities as well: =C2=BB pgrep Xorg 1401 =C2=BB sudo ps -e -p 1401 PID TT STAT TIME COMMAND 1401 v0 S 646:37.30 /usr/local/bin/Xorg :0 -listen tcp (shows no environment and swallows the error) =C2=BB sudo procstat -e 1401 PID COMM ENVIRONMENT procstat: sysctl(kern.proc.env): Cannot allocate memory 1401 Xorg - I've tried to track this down and searched for similar bug reports, but all suggestions mentioned there do not work. 1) Both library functions internally use the sysctl() interface to retrieve= the information from the kernel. sysctl() uses _locked memory_ for transferring= the data. So, a resource limit may be hit. But even if I raise the locked memory soft and hard limits (``ulimit -l -H ...=C2=B4=C2=B4, the error stays. 2) Even if I raise **vm.max_wired** to make sure no global limit is reached, the error stays. There is another scenario which trigges the problem: When using the 'Cirrus CI' continuous build platform (which runs on Google compute engine to my knownledge), there is also a process whose environment cannot be retrieve with the system interfaces kvm_getenvv() / procstat_getenvv(): sysctl vm.max_wired vm.stats.vm.v_wire_count vm.max_wired: 331490 vm.stats.vm.v_wire_count: 136164 limits Resource limits (current): cputime infinity secs filesize infinity kB datasize 33554432 kB stacksize 524288 kB coredumpsize infinity kB memoryuse infinity kB memorylocked 131072 kB maxprocesses 8499 openfiles 116856 sbsize infinity bytes vmemoryuse infinity kB pseudo-terminals infinity swapuse infinity kB kqueues infinity umtxp infinity ps auxm USER PID %CPU %MEM VSZ RSS TT STAT STARTED TIME COMMAND root 25598 0.0 7.0 990596 291548 u0 S+ 23:58 0:12.63 ./cirrus-ci-agent -task-id 5900109814693888 -client-token d5950e87a4cc4ce89436b07589944d60 -server-token abae919382e6411787e4d67fc60d= d527 -api-endpoint grpc.cirrus-ci.com:443 root 1 0.0 0.0 9788 284 - ILs 23:52 0:00.01 /sbin/init -- root 453 0.0 0.0 10456 1460 - Ss 23:52 0:00.00 /sbin/devd [....] root 22 0.0 0.0 12320 1596 u0 Is+ 23:52 0:00.04 sh /etc/rc autoboot root 25548 0.0 0.0 12320 1848 u0 I+ 23:58 0:00.00 sh /etc/rc autoboot [....] root 0 0.0 0.0 0 320 - DLs 23:52 0:00.00 [kernel] [....] procstat -e 22 procstat: sysctl(kern.proc.env): Cannot allocate memory PID COMM ENVIRONMENT 22 sh - --=20 You are receiving this mail because: You are the assignee for the bug.=
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?bug-248537-227>