Modify

Ticket #5738 (closed Bugs: fixed)

Opened 3 years ago

Last modified 2 years ago

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:

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

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

Change History

comment:1 Changed 2 years ago by igaztanaga

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

Thanks fixed in trunk at revision: 76118

comment:2 Changed 2 years ago by andysem

  • Status changed from closed to reopened
  • Resolution fixed deleted

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 2 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 2 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 2 years ago by andysem

The patch that fixes initial address of mapped region.

comment:5 Changed 2 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 2 years ago by igaztanaga

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

comment:7 Changed 2 years ago by igaztanaga

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

Merged to release branch.

View

Add a comment

Modify Ticket

Change Properties
<Author field>
Action
as closed
The resolution will be deleted. Next status will be 'reopened'
Author


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

 
Note: See TracTickets for help on using tickets.