Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What are the "rwxp" sections in /proc/pid/smaps (linux)

I have a C++ gcc leaking program with 326 sections like the following

33300000-33500000 rwxp 33300000 00:00 0
Size:              2048 kB
Rss:                620 kB
Shared_Clean:         0 kB
Shared_Dirty:         0 kB
Private_Clean:      244 kB
Private_Dirty:      376 kB

I was wondering what kind of allocation cause additions of 2MB writable code segments to the program. Usually I see such sections which are used as stack memory for threads but they are 10 MB large.

like image 673
Avner Levy Avatar asked Sep 14 '25 21:09

Avner Levy


2 Answers

r = read
w = write
x = execute
s = shared
p = private (copy on write)
like image 149
Skynet Avatar answered Sep 17 '25 02:09

Skynet


Usually I see such sections which are used as stack memory for threads

Yes, it is exceedingly likely that you are leaking threads. You can confirm this by looking in /proc/<pid>/task and checking whether you have 326 threads more than you expect. Alternatively, GDB info thread will also list all threads.

Note: the fact that your stacks are executable means that you don't have GNU_STACK segment in your binary or one of its required shared libraries, which is a generally a bad idea.

but they are 10 MB large.

The size of stack segments depends on current ulimit -s setting, as well as any setrlimit(..., RLIMIT_STAck, ...) or pthread_attr_setstacksize() calls that the application itself may perform.

like image 37
Employed Russian Avatar answered Sep 17 '25 00:09

Employed Russian