From owner-freebsd-bugs@freebsd.org Sat Aug 8 14:41:41 2020 Return-Path: Delivered-To: freebsd-bugs@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 1EC123ADD81 for ; Sat, 8 Aug 2020 14:41:41 +0000 (UTC) (envelope-from bugzilla-noreply@freebsd.org) Received: from mailman.nyi.freebsd.org (unknown [127.0.1.3]) by mx1.freebsd.org (Postfix) with ESMTP id 4BP4g903fNz42MN for ; Sat, 8 Aug 2020 14:41:41 +0000 (UTC) (envelope-from bugzilla-noreply@freebsd.org) Received: by mailman.nyi.freebsd.org (Postfix) id 01FB93ADD08; Sat, 8 Aug 2020 14:41:41 +0000 (UTC) Delivered-To: bugs@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 01C423ADD80 for ; Sat, 8 Aug 2020 14:41:41 +0000 (UTC) (envelope-from bugzilla-noreply@freebsd.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4BP4g86LL3z42V2 for ; Sat, 8 Aug 2020 14:41:40 +0000 (UTC) (envelope-from bugzilla-noreply@freebsd.org) Received: from kenobi.freebsd.org (kenobi.freebsd.org [IPv6:2610:1c1:1:606c::50:1d]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id BE25F9FE5 for ; Sat, 8 Aug 2020 14:41:40 +0000 (UTC) (envelope-from bugzilla-noreply@freebsd.org) Received: from kenobi.freebsd.org ([127.0.1.5]) by kenobi.freebsd.org (8.15.2/8.15.2) with ESMTP id 078EfeJF016909 for ; Sat, 8 Aug 2020 14:41:40 GMT (envelope-from bugzilla-noreply@freebsd.org) Received: (from www@localhost) by kenobi.freebsd.org (8.15.2/8.15.2/Submit) id 078Efeo4016908 for bugs@FreeBSD.org; Sat, 8 Aug 2020 14:41:40 GMT (envelope-from bugzilla-noreply@freebsd.org) X-Authentication-Warning: kenobi.freebsd.org: www set sender to bugzilla-noreply@freebsd.org using -f From: bugzilla-noreply@freebsd.org To: bugs@FreeBSD.org Subject: [Bug 248537] procstat -e/kvm_getenvv() fails for specific processes Date: Sat, 08 Aug 2020 14:41:40 +0000 X-Bugzilla-Reason: AssignedTo X-Bugzilla-Type: new X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: Base System X-Bugzilla-Component: kern X-Bugzilla-Version: 12.1-RELEASE X-Bugzilla-Keywords: X-Bugzilla-Severity: Affects Some People X-Bugzilla-Who: ag-freebsd@muc.de X-Bugzilla-Status: New X-Bugzilla-Resolution: X-Bugzilla-Priority: --- X-Bugzilla-Assigned-To: bugs@FreeBSD.org X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: bug_id short_desc product version rep_platform op_sys bug_status bug_severity priority component assigned_to reporter Message-ID: Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Bugzilla-URL: https://bugs.freebsd.org/bugzilla/ Auto-Submitted: auto-generated MIME-Version: 1.0 X-BeenThere: freebsd-bugs@freebsd.org X-Mailman-Version: 2.1.33 Precedence: list List-Id: Bug reports List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 08 Aug 2020 14:41:41 -0000 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.=