Bug 418756

Summary: MAP_FIXED_NOREPLACE mmap flag unsupported
Product: [Developer tools] valgrind Reporter: Stas Sergeev <stsp2>
Component: generalAssignee: Mark Wielaard <mark>
Status: RESOLVED FIXED    
Severity: normal CC: mark
Priority: NOR    
Version First Reported In: 3.15 SVN   
Target Milestone: ---   
Platform: Other   
OS: Linux   
Latest Commit: Version Fixed/Implemented In:
Sentry Crash Report:
Bug Depends on:    
Bug Blocks: 506971    

Description Stas Sergeev 2020-03-12 00:23:37 UTC
SUMMARY
valgrind doesn't support MAP_FIXED_NOREPLACE mmap flag,
causing the programs that use it, to misbehave.
Comment 1 Mark Wielaard 2025-07-15 19:47:31 UTC
This is also why the LTP testcase mmap17 fails.
mmap17.c:59: TFAIL: mmap failed, with unexpected error code, expected EEXIST:EACCES (13)
Uses MAP_FIXED_NOREPLACE. Tries to check that mmap at an exisiting mapping fails with EEXIST, not EACCES.
Comment 2 Mark Wielaard 2025-07-15 22:04:29 UTC
commit cad20f3e7d42e6371896e2492f0fc3a081314238
Author: Mark Wielaard <mark@klomp.org>
Date:   Tue Jul 15 23:49:36 2025 +0200

    Support mmap MAP_FIXED_NOREPLACE if defined
    
    Define VKI_MAP_FIXED_NOREPLACE for amd64-linux, arm-linux,
    arm64-linux, mips32-linux, mips64-linux, riscv64-linux and x86-linux.
    
    If it is defined then ML_(generic_PRE_sys_mmap) will also interpret
    VKI_MAP_FIXED_NOREPLACE as an MFixed hint. If the aspace manager
    doesn't find a MAP_FIXED_NOREPLACE ok, then fail with EEXIST. If the
    actual kernel mmap request fails and MAP_FIXED_NOREPLACE is set also
    immediately fail with EEXIST without retrying.
    
    This fixes the LTP mmap17 testcase.
    
    https://bugs.kde.org/show_bug.cgi?id=418756