https://bugs.kde.org/show_bug.cgi?id=470244

            Bug ID: 470244
           Summary: mremap() call not fully implemented fully and when
                    attempting to resize the same address to a larger size
                    the merman() call failed with FAILED.
    Classification: Developer tools
           Product: valgrind
           Version: 3.21.0
          Platform: RedHat Enterprise Linux
                OS: Linux
            Status: REPORTED
          Severity: grave
          Priority: NOR
         Component: general
          Assignee: jsew...@acm.org
          Reporter: victor.unitie...@icloud.com
  Target Milestone: ---

Created attachment 159239
  --> https://bugs.kde.org/attachment.cgi?id=159239&action=edit
program to demonstrate the issue

SUMMARY
Under valgrind the call to mremap() failed with MAP_FAILED because the
overloading valgrind mremap() doesn't implement increasing the size of the
memory at the same address fully.  I assume this is because the valgrind calls
are more malloc/free oriented and assume its ok to change the address on a
resize.

STEPS TO REPRODUCE
1.  Compile example program which uses mmap/mremap/munmap() calls
2. Run from command line with and without valgrind.

OBSERVED RESULT
# valgrind -v --tool=memcheck ./a.out
init mmap: size:8192
grow mmap: oldaddr:0xac00000000 oldsize:8192 newsize:16384
Failed mremap mmmap.dat (12:Cannot allocate memory)
zsh: abort (core dumped)  valgrind -v --tool=memcheck ./a.out

EXPECTED RESULT
When running the program without valgrind the system allows for the base
address to be expanded in size.
# ./a.out
init mmap: size:8192
grow mmap: oldaddr:0xac00000000 oldsize:8192 newsize:16384
mremap: addr:0xac00000000 size:16384
That's all folks

SOFTWARE/OS VERSIONS
Any Linux (I ran my tests on RHEL8.8)
Kernel: Linux4.18.0-425.19.2.el8_7.x86_64 #1 SMP Fri Mar 17 01:52:38 EDT 2023
x86_64 x86_64 x86_64 GNU/Linux

ADDITIONAL INFORMATION
The solution this code is a key component of a in memory database.. We do out
own address management so as not to conflict with HI/LO memory allocation.
Hence we start at address 0xAC00000000L.  When we allocate  mmaps we leave
enough address space between the addresses so that mremap has enough contiguous
memory to succeed with no conflict.

If there is a work around for avoiding this issue that would be helpful, for
instance can I disable the valgrind mmap support?
We don't need it to investigate mmap() issues.

-- 
You are receiving this mail because:
You are watching all bug changes.

Reply via email to