This is the mail archive of the
libc-alpha@sourceware.org
mailing list for the glibc project.
Re: [PATCH 2/2][BZ #12416] Use stack boundaries from /proc/PID/mapsto make stack executable
- From: Siddhesh Poyarekar <siddhesh at redhat dot com>
- To: KOSAKI Motohiro <kosaki dot motohiro at gmail dot com>
- Cc: Roland McGrath <roland at hack dot frob dot com>, libc-alpha at sourceware dot org
- Date: Tue, 12 Jun 2012 03:08:15 +0530
- Subject: Re: [PATCH 2/2][BZ #12416] Use stack boundaries from /proc/PID/mapsto make stack executable
- References: <20120419120021.4780e8c8@spoyarek><20120425203424.A744A2C0CA@topped-with-meat.com><20120426123653.765f1462@spoyarek><20120504231020.AF7C92C093@topped-with-meat.com><20120507084337.6d1ea127@spoyarek><20120507200221.963992C099@topped-with-meat.com><20120508161750.063e9791@spoyarek><20120514234622.30D472C09E@topped-with-meat.com><20120515081610.1b4aee17@spoyarek><20120515163033.CD04B2C08B@topped-with-meat.com><20120516123338.55cd9a34@spoyarek><CAHGf_=p3QUrym2+LBSsB+n0faog=kSK1bTu-AAnCCGYxbDEUkw@mail.gmail.com>
On 12 June 2012 02:44, KOSAKI wrote:
> I received a complains against this change from ruby folks. Because
> of, ruby interpreter show special error message when stack overflow is
> detected. and they assume "stackaddr - stacksize" point to stack edge.
>
> But this patch only changed stackaddr. thus the assuption broke.
> Is there any chance to change stacksize too?
Can you or the ruby devs please give a more detailed explanation of the
problem they're seeing? The patch does in fact change the stack size if
the distance of the stack bottom from the vma immediately below the
stack top is less than the stack rlimit. From nptl/pthread_getattr_np.c:
iattr->stacksize = rl.rlim_cur;
iattr->stackaddr = stack_end;
/* The limit might be too high. */
if ((size_t) iattr->stacksize
> (size_t) iattr->stackaddr - last_to)
iattr->stacksize = (size_t) iattr->stackaddr -
last_to;
See how stacksize is derived from stackaddr, which in this case is the
stack bottom. In fact, the stackaddr you get from
pthread_attr_getstack() is again derived from the stack bottom and
stack size to get the stack top, so doing stackaddr - stacksize with
that value will lead you nowhere.
pthread_attr_getstackaddr does return the bottom of stack but that
function is deprecated and that usage should be replaced with
pthread_attr_getstack.
A reproducer would help to understand what they're seeing.
Regards,
Siddhesh