Opened 11 years ago

Closed 11 years ago

#5738 closed Bugs (fixed)

Default-constructed mapped_region address is not NULL

Reported by: Andrey Semashev Owned by: Ion Gaztañaga
Milestone: To Be Determined Component: interprocess
Version: Boost 1.47.0 Severity: Regression
Keywords: Cc:

Description

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 Andrey Semashev 11 years ago.
The patch that fixes initial address of mapped region.

Download all attachments as: .zip

Change History (8)

comment:1 by Ion Gaztañaga, 11 years ago

Resolution: fixed
Status: newclosed

Thanks fixed in trunk at revision: 76118

comment:2 by Andrey Semashev, 11 years ago

Resolution: fixed
Status: closedreopened

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 by anonymous, 11 years ago

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 by Andrey Semashev, 11 years ago

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.

by Andrey Semashev, 11 years ago

Attachment: mapped_region.patch added

The patch that fixes initial address of mapped region.

comment:5 by Andrey Semashev, 11 years ago

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 by Ion Gaztañaga, 11 years ago

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

comment:7 by Ion Gaztañaga, 11 years ago

Resolution: fixed
Status: reopenedclosed

Merged to release branch.

Note: See TracTickets for help on using tickets.