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:
Created attachment 88086 [details] test program
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"
Explanation posted seems good, resolving as notabug.
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.