From owner-freebsd-hackers@FreeBSD.ORG Mon May 10 14:58:22 2010 Return-Path: Delivered-To: freebsd-hackers@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id 0B89410657A4 for ; Mon, 10 May 2010 14:58:22 +0000 (UTC) (envelope-from kostikbel@gmail.com) Received: from mail.zoral.com.ua (mx0.zoral.com.ua [91.193.166.200]) by mx1.freebsd.org (Postfix) with ESMTP id 785C08FC13 for ; Mon, 10 May 2010 14:58:21 +0000 (UTC) Received: from deviant.kiev.zoral.com.ua (root@deviant.kiev.zoral.com.ua [10.1.1.148]) by mail.zoral.com.ua (8.14.2/8.14.2) with ESMTP id o4AEwH7r083238 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Mon, 10 May 2010 17:58:17 +0300 (EEST) (envelope-from kostikbel@gmail.com) Received: from deviant.kiev.zoral.com.ua (kostik@localhost [127.0.0.1]) by deviant.kiev.zoral.com.ua (8.14.4/8.14.4) with ESMTP id o4AEwHAg011619; Mon, 10 May 2010 17:58:17 +0300 (EEST) (envelope-from kostikbel@gmail.com) Received: (from kostik@localhost) by deviant.kiev.zoral.com.ua (8.14.4/8.14.4/Submit) id o4AEwHGp011618; Mon, 10 May 2010 17:58:17 +0300 (EEST) (envelope-from kostikbel@gmail.com) X-Authentication-Warning: deviant.kiev.zoral.com.ua: kostik set sender to kostikbel@gmail.com using -f Date: Mon, 10 May 2010 17:58:17 +0300 From: Kostik Belousov To: Lev Serebryakov Message-ID: <20100510145817.GO83316@deviant.kiev.zoral.com.ua> References: <1127023465.20100510115708@serebryakov.spb.ru> Mime-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="NT59pYSnj1ZLVgEN" Content-Disposition: inline In-Reply-To: <1127023465.20100510115708@serebryakov.spb.ru> User-Agent: Mutt/1.4.2.3i X-Virus-Scanned: clamav-milter 0.95.2 at skuns.kiev.zoral.com.ua X-Virus-Status: Clean X-Spam-Status: No, score=-2.5 required=5.0 tests=ALL_TRUSTED,AWL,BAYES_40, DNS_FROM_OPENWHOIS autolearn=no version=3.2.5 X-Spam-Checker-Version: SpamAssassin 3.2.5 (2008-06-10) on skuns.kiev.zoral.com.ua Cc: freebsd-hackers@freebsd.org Subject: Re: How to get stack bounds of current process? X-BeenThere: freebsd-hackers@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Technical Discussions relating to FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 10 May 2010 14:58:22 -0000 --NT59pYSnj1ZLVgEN Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Mon, May 10, 2010 at 11:57:08AM +0400, Lev Serebryakov wrote: > Hello, Freebsd-hackers. >=20 > I'm proting some application from Linux, which discover its stack > bounds by reading and pasing "/proc/self/maps". FreeBSD have > "/prov/curproc/map", but I can not find how to determine which record > is for stack (I've looked into implementation of proc_fs, but it > doesn't contain any specail processing for process stack). >=20 > How could I determine stack bounds of current process on FreeBSD > 7/8/9? I think the right question is why the program needs the information at all. Really, the system has no data to answer your question. Which stack are you asking for ? The stack of main thread, set up by kernel, is very different from the stack established by the threading library for newly created thread. What should happen for signal altstacks ? Also, the threading library clips the main thread stack to match its size with default stack size (I do think this is unsafe and wrong). Also, the application can legitimately allocate arbitrary memory region and use it as the stack (this is essentially what threading library does). --NT59pYSnj1ZLVgEN Content-Type: application/pgp-signature Content-Disposition: inline -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.10 (FreeBSD) iEYEARECAAYFAkvoHwgACgkQC3+MBN1Mb4jjIgCgyFjGlYaXqAWix7L3+8ck83nx hHIAoOsVsn68hXRCYQIk3P3v7EWbrzSJ =yJWW -----END PGP SIGNATURE----- --NT59pYSnj1ZLVgEN--