This is the mail archive of the binutils@sourceware.org mailing list for the binutils project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: "rwxp" permissions for pthread stack and guard pages "---p" leak on ARM


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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]