From owner-freebsd-hackers@freebsd.org Fri Sep 11 14:38:23 2020 Return-Path: Delivered-To: freebsd-hackers@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 0FE823DCD45 for ; Fri, 11 Sep 2020 14:38:23 +0000 (UTC) (envelope-from shawn.webb@hardenedbsd.org) Received: from mail-qk1-x744.google.com (mail-qk1-x744.google.com [IPv6:2607:f8b0:4864:20::744]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (2048 bits) client-digest SHA256) (Client CN "smtp.gmail.com", Issuer "GTS CA 1O1" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4Bnyzf1sDKz4RRQ for ; Fri, 11 Sep 2020 14:38:22 +0000 (UTC) (envelope-from shawn.webb@hardenedbsd.org) Received: by mail-qk1-x744.google.com with SMTP id p4so10090522qkf.0 for ; Fri, 11 Sep 2020 07:38:22 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=hardenedbsd.org; s=google; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to; bh=TQl2Ea6pcaN+TmZjtAylXWl9iKvgFeDgaoNPUypUCi8=; b=fl4gPlnk09TbSMy4MR6UXtdu74l99oL30blUeHkVTBux2m6OJO8HlyAPQ21ClphQLX VM9StrfzIjBSIM9qy1SVeglPadz2QArPN/Gflba6GphtxlqScgPira2cElkB5iwZ6fF2 URqRHizhpLiauWa/2PlTZtItTLdcQtSWLuhzMT7dyv4KvB391ScaxeoyoUzjGnYoVzgo knvvyX+h3Dv+IJx+95IQA3qj15RA8ZuJEAFhfrE95K6AUFv3kdvRVmiBF8/NeP9bzYNH pn9eNKJa/4/jV7kjnSoZTf/wHarHnfMk/e9ei9PLVMJ7KgIJ10cLC//gmk4VnzUDZDUU pCAg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=TQl2Ea6pcaN+TmZjtAylXWl9iKvgFeDgaoNPUypUCi8=; b=poZyLuQfmZulNd3OsdDA0JGv3F+o29/wE2E1b9SVLKFwJTYd9y9o5uxJ2pT5EcFny2 IEIiDYgYSWEYU1NzCEhRTd8jbxR7mgr0/r9ib0ETVCDfaj4Hf8PsE81vmBvsxig4NGqv Ih+xxmnzToqnT+iFxzwxYaiRaNECd963Sj2tjt5/u1cvwAGz/brLVhhzpa4vem7VkGbI pf0Zf1/8tWdorM292auODXnIMakkv+LFTNcbnuql0tcsILQ2GCnw/fZQowaWfmZ1fNI2 NGYlNvWoMdqhwTmQ2ZL9/feD4BeXchfyO5Rr5ZFFRu89rwFuoPV9C0xO2838ORdoMdDw fKzQ== X-Gm-Message-State: AOAM531EWgCvYFlGgvlll1ecSWGyO7FLzbn5Ag2N84aASus1i6W5g9Jm cY4pOfJuEPzQahFlGa9wuvVPzcx969zt3g== X-Google-Smtp-Source: ABdhPJy7o8v5zfREKB053JGEDFHDGm9OBIo8n+u182qOFI1SsCxUAf9bcfRzm+wAULyzE3fFUSxDXg== X-Received: by 2002:a37:5dc6:: with SMTP id r189mr1754179qkb.364.1599835101416; Fri, 11 Sep 2020 07:38:21 -0700 (PDT) Received: from mutt-hbsd (75-148-2-186-WashingtonDC.hfc.comcastbusiness.net. [75.148.2.186]) by smtp.gmail.com with ESMTPSA id 10sm2921786qkk.88.2020.09.11.07.38.19 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 11 Sep 2020 07:38:19 -0700 (PDT) Date: Fri, 11 Sep 2020 10:38:15 -0400 From: Shawn Webb To: SHAMANTHA KRISHNA K G Cc: Ian Lepore , freebsd-hackers@freebsd.org Subject: Re: Determing Heap and stack size of running process. Message-ID: <20200911143815.77d675abityetbme@mutt-hbsd> X-Operating-System: FreeBSD mutt-hbsd 13.0-CURRENT-HBSD FreeBSD 13.0-CURRENT-HBSD X-PGP-Key: http://pgp.mit.edu/pks/lookup?op=vindex&search=0xFF2E67A277F8E1FA References: <2db16d9822eab8fb536eaf705d6378487c7994ae.camel@freebsd.org> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="yzybwqftyuawtm5t" Content-Disposition: inline In-Reply-To: X-Rspamd-Queue-Id: 4Bnyzf1sDKz4RRQ X-Spamd-Bar: ----- Authentication-Results: mx1.freebsd.org; dkim=pass header.d=hardenedbsd.org header.s=google header.b=fl4gPlnk; dmarc=none; spf=pass (mx1.freebsd.org: domain of shawn.webb@hardenedbsd.org designates 2607:f8b0:4864:20::744 as permitted sender) smtp.mailfrom=shawn.webb@hardenedbsd.org X-Spamd-Result: default: False [-5.14 / 15.00]; RCVD_VIA_SMTP_AUTH(0.00)[]; ARC_NA(0.00)[]; R_DKIM_ALLOW(-0.20)[hardenedbsd.org:s=google]; NEURAL_HAM_MEDIUM(-0.96)[-0.959]; FROM_HAS_DN(0.00)[]; RCPT_COUNT_THREE(0.00)[3]; TO_DN_SOME(0.00)[]; R_SPF_ALLOW(-0.20)[+ip6:2607:f8b0:4000::/36]; MIME_GOOD(-0.20)[multipart/signed,text/plain]; PREVIOUSLY_DELIVERED(0.00)[freebsd-hackers@freebsd.org]; DMARC_NA(0.00)[hardenedbsd.org]; NEURAL_HAM_LONG(-0.98)[-0.980]; RCVD_COUNT_THREE(0.00)[3]; TO_MATCH_ENVRCPT_SOME(0.00)[]; DKIM_TRACE(0.00)[hardenedbsd.org:+]; NEURAL_HAM_SHORT(-1.10)[-1.099]; RCVD_IN_DNSWL_NONE(0.00)[2607:f8b0:4864:20::744:from]; SIGNED_PGP(-2.00)[]; FREEMAIL_TO(0.00)[gmail.com]; FROM_EQ_ENVFROM(0.00)[]; MIME_TRACE(0.00)[0:+,1:+,2:~]; MID_RHS_NOT_FQDN(0.50)[]; ASN(0.00)[asn:15169, ipnet:2607:f8b0::/32, country:US]; RCVD_TLS_ALL(0.00)[]; MAILMAN_DEST(0.00)[freebsd-hackers] X-BeenThere: freebsd-hackers@freebsd.org X-Mailman-Version: 2.1.33 Precedence: list List-Id: Technical Discussions relating to FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 11 Sep 2020 14:38:23 -0000 --yzybwqftyuawtm5t Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable Given that jemalloc uses anonymous pages, it's not really possible to tell which anonymous pages come from jemalloc's calls to mmap. A number of applications, especially those with JITs, also create anonymous memory mappings. One could infer stack usage by the MAP_STACK flag. Pages marked with MAP_GUARD are definitely not pages destined for the heap (I doubt jemalloc makes use of the relatively new MAP_GUARD flag, though I haven't checked.) Thanks, --=20 Shawn Webb Cofounder / Security Engineer HardenedBSD GPG Key ID: 0xFF2E67A277F8E1FA GPG Key Fingerprint: D206 BB45 15E0 9C49 0CF9 3633 C85B 0AF8 AB23 0FB2 https://git-01.md.hardenedbsd.org/HardenedBSD/pubkeys/src/branch/master/Sha= wn_Webb/03A4CBEBB82EA5A67D9F3853FF2E67A277F8E1FA.pub.asc On Fri, Sep 11, 2020 at 07:59:01PM +0530, SHAMANTHA KRISHNA K G wrote: > Any idea about the fields which have no PRT( I mean no protections flag s= et > --- no read no write no execute) and no flags and with mapping type 'df' = ?. >=20 > Thanks , > -Shamantha. >=20 > On Fri, 11 Sep 2020, 19:31 Ian Lepore, wrote: >=20 > > On Fri, 2020-09-11 at 19:26 +0530, SHAMANTHA KRISHNA K G wrote: > > > Thank you for the heads up, I had tried the output of procstat > > > -v also > > > ,there also I am not getting any information about heap usage . > > > > > > Thanks > > > -Shamantha > > > > > > > The output does tell you about heap usage, but you have to interpret > > the type and flags to figure out which mappings are heap allocations, > > and the RES count to figure out how many pages of those mappings are > > actually in use (i.e., backed by physical ram). > > > > Iirc, the mappings with type 'df' and no flags set are the heap > > allocations, but I'm not positive of that. Things with the D flag set > > are thread stacks. I remember the manpage wasn't all that helpful in > > figuring that stuff out last time I needed to know. > > > > -- Ian > > > > > > > > > > > > > > > > > > > > > > > On Fri, 11 Sep 2020, 18:59 Ian Lepore, wrote: > > > > > > > On Fri, 2020-09-11 at 16:36 +0530, SHAMANTHA KRISHNA K G wrote: > > > > > Hello All, > > > > > I want to know the *size of heap and stack for a running > > > > > process* ,how > > > > > it can be done, if I* don't *see any* [stack ] *or* [heap] > > > > > *in the > > > > > output > > > > > of */proc/pid/map* and also the platform does not allow > > > > > installing > > > > > *third party > > > > > freebsd utilities like valgrind.* > > > > > > > > > > Thank you, > > > > > -Shamantha > > > > > > > > > > > > > Use procstat(1). For example "procstat -v " will show all the > > > > memory mappings for that process. If you need it from within a > > > > program > > > > you're writing, "man libprocstat" will get you some info on how > > > > procstat(1) does its work. > > > > > > > > -- Ian > > > > > > > > > > > > > > _______________________________________________ > > > freebsd-hackers@freebsd.org mailing list > > > https://lists.freebsd.org/mailman/listinfo/freebsd-hackers > > > To unsubscribe, send any mail to " > > > freebsd-hackers-unsubscribe@freebsd.org" > > > > > _______________________________________________ > freebsd-hackers@freebsd.org mailing list > https://lists.freebsd.org/mailman/listinfo/freebsd-hackers > To unsubscribe, send any mail to "freebsd-hackers-unsubscribe@freebsd.org" --yzybwqftyuawtm5t Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iQIzBAABCAAdFiEEA6TL67gupaZ9nzhT/y5nonf44foFAl9bi9QACgkQ/y5nonf4 4fpfDBAAn5lhCa9TcnttMUpuc9lxnCkhTRBDswahI5mooOO390O/zlPntMuhN1Af 1GmB3JBcQse7F/bA0Faya8qnLVOsh2Dag42YGo6KW0FfDB0aT6KIB9hBTXSal2TG heNTGoHIez51c6xU9D9/Yx25/F5XB4rj7kqqPrmiE8GfsGAuS9+xvHE4fLtyfiY1 9ZuJc1+4/qzFw9EaHrHxDsWZLH3pPxPWrkm335XBlt1SbyNE4YJ4m3AWCjplm6+H O8nExtQPk7+k1Octh6pqmz6qk9THNnyx652A6qsLbgBwEEoLIYOt1lo4MgJIJFdk ahCP8O5Q7vAeKyP5Trac7yPUDW8B5cZh1jbs0VBf4SHjIq0NWre7bDdFbnDqIJKl qfXO2Er8MflS4FiltsfuqcbyoLcxtLVls05MN0/wHZNXywkcAIR1Fsd2AqlULT23 Npm7fSDFVHd1UGADzPHTw6BpkDA5Ew4WQGtwb30ObQwMA5t29F3kV3ndGQMGBg9e 0XWJc7OHJzY60H9KGh6umQKZLustqYo4Jc+CbxHXLslhMfICPwg2w76C4TmyHQOV 0qmHPKwVnow3KUws2luHN8Gr1wEa9AwcP2rw1aBMg/z1TwPNnZT3azXJsTsJBhX4 NvupPLhf67bUOwsMH8OFyQYE1K0YJGK9RjXDhoxG7mQ2eHGtwV0= =dCFB -----END PGP SIGNATURE----- --yzybwqftyuawtm5t--