Opened 6 years ago

Closed 5 years ago

#5738 closed Bugs (fixed)

Default-constructed mapped_region address is not NULL

Reported by: andysem Owned by: igaztanaga
Milestone: To Be Determined Component: interprocess
Version: Boost 1.47.0 Severity: Regression
Keywords: Cc:


On POSIX systems, the default-constructed mapped_region address is initialized with MAP_FAILED constant, which is not 0 (at least, on Linux). This contradicts documentation, which states that the initial address will be 0.

Attachments (1)

mapped_region.patch (8.2 KB) - added by andysem 6 years ago.
The patch that fixes initial address of mapped region.

Download all attachments as: .zip

Change History (8)

comment:1 Changed 6 years ago by igaztanaga

  • Resolution set to fixed
  • Status changed from new to closed

Thanks fixed in trunk at revision: 76118

comment:2 Changed 6 years ago by andysem

  • Resolution fixed deleted
  • Status changed from closed to reopened

I see you changed the documentation rather than implementation. I think it would be better to make initial address to be NULL on all platforms rather than some unspecified value. Sorry, I didn't make my intention clear in the ticket. I'll reopen it so that it doesn't get lost.

comment:3 Changed 6 years ago by anonymous

I don't like the idea of making the address null on all platforms. In UNIX MAP_FAILED is not NULL and I don't think I should add a branch in the inline get_address to convert map_failed to null, confusing UNIX users. I've committed another change, creating an additional invalid_address() static function that returns a portable invalid address constant (0 in windows, MAP_FAILED in unix). Let me know if you think this can be enough to close the bug.

comment:4 Changed 6 years ago by andysem

I didn't mean to add a branch to get_address. The idea was to process MAP_FAILED internally, when mmap is called, and always use NULL to indicate the invalid address to users. I think NULL is the commonly used value for pointers to indicate address validity, so there is no need to introduce another constant for this. In fact, I consider MAP_FAILED constant as a bad legacy of the mmap function interface. I'll try to prepare a patch to illustrate my suggestion.

Changed 6 years ago by andysem

The patch that fixes initial address of mapped region.

comment:5 Changed 6 years ago by andysem

See the attached patch. I removed the invalid_address function as there is no need for it anymore. If you feel for it, you can leave it there, in which case it should always return NULL on all platforms.

comment:6 Changed 5 years ago by igaztanaga

Thanks for the patch, tested and committed (revision 76200).

comment:7 Changed 5 years ago by igaztanaga

  • Resolution set to fixed
  • Status changed from reopened to closed

Merged to release branch.

Add Comment

Modify Ticket

Change Properties
Set your email in Preferences
as closed The owner will remain igaztanaga.
The resolution will be deleted. Next status will be 'reopened'.

E-mail address and user name can be saved in the Preferences.

Note: See TracTickets for help on using tickets.