Bug 79311

Summary: mmap MAP_SHARED doesn't work in one process
Product: [Retired] Red Hat Linux Reporter: Need Real Name <jboorn>
Component: kernelAssignee: Arjan van de Ven <arjanv>
Status: CLOSED NOTABUG QA Contact: Brian Brock <bbrock>
Severity: medium Docs Contact:
Priority: medium    
Version: 7.3   
Target Milestone: ---   
Target Release: ---   
Hardware: i686   
OS: Linux   
Whiteboard:
Fixed In Version: Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2003-03-26 00:11:30 UTC Type: ---
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:
Attachments:
Description Flags
test program none

Description Need Real Name 2002-12-09 22:43:21 UTC
From Bugzilla Helper:
User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.0.1) Gecko/20021003

Description of problem:
It appears that if mmap is called more than once on the same file in a single
process the flag MAP_SHARED is ignored, and a new memory is allocated for the
mapping.  Test code attached, save as t.c, compile with gcc -o t t.c, and run ./t.

test system is RedHat 7.3, kernel-smp-2.4.18-18.7.x, 
glibc-kernheaders-2.4-7.16, gcc-2.96-113, glibc-2.2.5-42.

Version-Release number of selected component (if applicable):


How reproducible:
Always

Steps to Reproduce:
1.compile attached code
2.run attaced code
3.see pointer is different
	

Actual Results:  output of attached program is:
mp1 = 0x40014000
mp2 = 0x40016000


Expected Results:  mp1 = 0x40014000
mp2 = 0x40014000


Additional info:

Comment 1 Need Real Name 2002-12-09 22:46:41 UTC
Created attachment 88086 [details]
test program

Comment 2 Arjan van de Ven 2002-12-10 08:29:58 UTC
ehm
you ask for 2 mappings of the same file, you get 2 mappings; it will be the same
physical page however, just available at both addresses; MAP_SHARED doesn't mean
"return same virtual address" but "share phsyical memory between mmap users"

Comment 3 Brian Brock 2003-03-26 00:11:30 UTC
Explanation posted seems good, resolving as notabug.

Comment 4 Need Real Name 2003-03-26 18:38:40 UTC
Technically not a bug.  My problem, which was worked around with a wrapper, was
the process would run out of memory after mmaping a large file a second time. 
This seems undiserable to me,the process ran out of memory while not using any
more real memory.