Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7065519
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T04:57:58+00:00 2026-05-28T04:57:58+00:00

When I run the following code, int x[4096]; int *y; int *m; void main()

  • 0

When I run the following code,

int x[4096];
int *y;
int *m;

void main()
{
    y = (int*)malloc( 4096 * sizeof(int) );
    m = (int*)mmap( 0, 4096 * sizeof(int), PROT_READ | PROT_WRITE, 
MAP_PRIVATE | MAP_ANONYMOUS, -1, 0 );

    printf( "x = %p, y = %p, m = %p\n\n", x, y, m );

    system( "cat /proc/self/maps" );
}

I get the following output,

x = 0x601060, y = 0x606010, m = 0x7ffff7ff5000

00400000-0040b000 r-xp 00000000 08:01 655382                             /bin/cat
0060a000-0060b000 r--p 0000a000 08:01 655382                             /bin/cat
0060b000-0060c000 rw-p 0000b000 08:01 655382                             /bin/cat
0060c000-0062d000 rw-p 00000000 00:00 0                                  [heap]
7ffff77b5000-7ffff7a59000 r--p 00000000 08:01 395618                     /usr/lib/locale/locale-archive
7ffff7a59000-7ffff7bd3000 r-xp 00000000 08:01 1062643                    /lib/libc-2.12.1.so
7ffff7bd3000-7ffff7dd2000 ---p 0017a000 08:01 1062643                    /lib/libc-2.12.1.so
7ffff7dd2000-7ffff7dd6000 r--p 00179000 08:01 1062643                    /lib/libc-2.12.1.so
7ffff7dd6000-7ffff7dd7000 rw-p 0017d000 08:01 1062643                    /lib/libc-2.12.1.so
7ffff7dd7000-7ffff7ddc000 rw-p 00000000 00:00 0 
7ffff7ddc000-7ffff7dfc000 r-xp 00000000 08:01 1062651                    /lib/ld-2.12.1.so
7ffff7fd9000-7ffff7fdc000 rw-p 00000000 00:00 0 
7ffff7ff9000-7ffff7ffb000 rw-p 00000000 00:00 0 
7ffff7ffb000-7ffff7ffc000 r-xp 00000000 00:00 0                          [vdso]
7ffff7ffc000-7ffff7ffd000 r--p 00020000 08:01 1062651                    /lib/ld-2.12.1.so
7ffff7ffd000-7ffff7ffe000 rw-p 00021000 08:01 1062651                    /lib/ld-2.12.1.so
7ffff7ffe000-7ffff7fff000 rw-p 00000000 00:00 0 
7ffffffde000-7ffffffff000 rw-p 00000000 00:00 0                          [stack]
ffffffffff600000-ffffffffff601000 r-xp 00000000 00:00 0                  [vsyscall]

Now, my question is, why the memories allocated either as malloc, mmap or global data are not within the range of any mappings shown with /proc/self/maps?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-28T04:57:59+00:00Added an answer on May 28, 2026 at 4:57 am

    When you run system( "cat /proc/self/maps" ); you show the mappings of the cat process. You can see in the first lines of output that it is the cat executable that is mapped:

    00400000-0040b000 r-xp 00000000 08:01 655382                             /bin/cat
    

    You need to do snprintf(..., "cat /proc/%d/maps", getpid());, or open the /proc/self/pid file and read it you self in your own process.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Say we have the following code: int main(){ int a[3]={1,2,3}; printf( E: 0x%x\n, a);
When I run the following code: #include <stdio.h> int main(int argc, char *argv[]) {
if I compile (under G++) and run the following code it prints Foo::Foo(int). However
The following C# code takes 5 minutes to run: int i = 1; string
When I run the following code: private void button1_Click(object sender, EventArgs e) { Bitmap
I'm getting the above error when I try to run the following code: int
I have a thread that executes the following code: public void run() { try
It seems that when I run the following code: #include <stdio.h> #include <stdlib.h> int
I get a StackOverflowException when I run the following code: private void MyButton_Click(object sender,
I have discovered that if i run following lines of code. int i =

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.