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 8398319
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T21:01:23+00:00 2026-06-09T21:01:23+00:00

Although the requested mapping address is a page start, it will use an address

  • 0

Although the requested mapping address is a page start, it will use an address shifted with a few pages.

I’m trying to do something like this:

char *mapped = mmap(base, page_size, PROT_NONE, MAP_SHARED,
                    file_handle, 0);
printf("Base  : %p\n", base);
printf("Mapped: %p\n", mapped);

Sample output (page_size = 4096 = 0x1000):

Base  : 0x7f22a1047000
Mapped: 0x7f22a1045000

Offset is 2 pages. This also seems to vary with length. For example, if instead of one page I try to map 4 pages, output becomes:

Base  : 0x7fd24d994000
Mapped: 0x7fd24d98f000

which is 5 pages offset.

Why is it behaving like this?

  • 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-06-09T21:01:25+00:00Added an answer on June 9, 2026 at 9:01 pm

    Because the OS is, when you don’t specifically ask for a mapping at a fixed address, free to choose an address convenient for itself; from the mmap(2) man page:

    MAP_FIXED
              Don't interpret addr as a hint: place the mapping at exactly that
              address.  addr must be a multiple of the page size.  If the memory
              region specified by addr and len overlaps pages of any existing
              mapping(s), then the overlapped part of the existing mapping(s) will be
              discarded.  If the specified address cannot be used, mmap() will fail.
              Because requiring a fixed address for a mapping is less portable, the
              use of this option is discouraged.
    

    If you don’t need that exact address, you’re better off letting the system choose it (which, honestly, should be in the majority of cases).

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

Sidebar

Related Questions

I suspect this could be something faulty with Excel (although I keep an open
i'm trying to get full path of the requested url in Django. I use
Although this code is from an algorithm text, I have a bit of a
Although I have found some solutions to this problem, none of them refer to
Although I have read a few previously answered questions regarding a similar issue, I
I was using the topcoder C++ compiler, and although this code just run fine
I have this page, let's call it index.php index.php has a list of users
I've inherited an old Classic ASP website to modify. Although not requested up-front, I'd
I'm building a buffer in Java that will collect write actions requested by many
I'm trying to get the URL that has been requested in Python without using

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.