Skip site navigation (1)Skip section navigation (2)
Date:      Mon, 10 May 2010 17:58:17 +0300
From:      Kostik Belousov <kostikbel@gmail.com>
To:        Lev Serebryakov <lev@freebsd.org>
Cc:        freebsd-hackers@freebsd.org
Subject:   Re: How to get stack bounds of current process?
Message-ID:  <20100510145817.GO83316@deviant.kiev.zoral.com.ua>
In-Reply-To: <1127023465.20100510115708@serebryakov.spb.ru>
References:  <1127023465.20100510115708@serebryakov.spb.ru>

next in thread | previous in thread | raw e-mail | index | archive | help

--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--



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20100510145817.GO83316>