This is the mail archive of the
binutils@sourceware.org
mailing list for the binutils project.
Re: "rwxp" permissions for pthread stack and guard pages "---p" leak on ARM
- From: Ian Lance Taylor <iant at google dot com>
- To: Ravi Sankar <ravisankar dot g at gmail dot com>
- Cc: binutils at sourceware dot org
- Date: Tue, 06 Oct 2009 13:08:06 -0700
- Subject: Re: "rwxp" permissions for pthread stack and guard pages "---p" leak on ARM
- References: <f4ce15480910060941u27e79456o5ab53b83bac0c8c2@mail.gmail.com>
Ravi Sankar <ravisankar.g@gmail.com> writes:
> Using glibc-2.5, Linux 2.6.24 on ARM Cortex -A8.
>
> I create a ntpl thread with attributes as "detached", and upon
> finishing the start routine of the thread it just "returns". (no
> pthread_exit call). Sometimes I observe that thread stack and its
> guard pages are still visible using /proc/pid/maps entry even after
> the thread exited. So in due course of time, as we keep on creating
> such threads the process runs out of VM.
>
> I would like to know,
>
> 1) Even though the thread was created as "detached" state, what makes
> the kernel?, pthread? to keep the thread stack and resources even
> after thread exit.
I think the right place to ask this would be a glibc mailing list. It
doesn't seem to have anything to do with the binutils. I think that
the NPTL pthreads library may cache and reuse thread stacks, although
that would not explain why you run out of VM.
> 2) Why thread stack should have "rwx" permissions instead of "rw"?
Stacks are created executable by default. To make them
non-executable, every object file must have a .note.GNU-stack section
which does not have the SHF_EXECINSTR flag set. This will be created
automatically by gcc. However, if you have any assembler sources in
your executable, then you need to manually add a line like
.section .note.GNU-stack,"",@progbits
Ian