https://bugs.kde.org/show_bug.cgi?id=374963
            Bug ID: 374963
           Summary: increase valgrind's load address to prevent mmap
                    failure
           Product: valgrind
           Version: 3.12.0
          Platform: unspecified
                OS: Linux
            Status: UNCONFIRMED
          Severity: wishlist
          Priority: NOR
         Component: general
          Assignee: jsew...@acm.org
          Reporter: roland_wi...@web.de
  Target Milestone: ---

Created attachment 103372
  --> https://bugs.kde.org/attachment.cgi?id=103372&action=edit
Patch to make valgrind work with -mcmodel=large

Valgrind startup fails when the executable contains large text, data or bss
segments (see also #138424):

    valgrind: mmap(0x602000, 933228544) failed in UME with error 22 (Invalid
argument).
    valgrind: this can be caused by executables with very large text, data or
bss segments.

Reason for this is valgrind's load address, which is set to 0x38000000 (on
amd64). Once the combined size of the text, data and bss segments is larger
than approx. 892 MiB, the executable image overlaps with valgrind's image and
the mmap call allocating space for the segments fails because part of the
requested address space is already in use.

The problem cannot be solved by mapping the segments in another location
because the location of the segments is hard-coded into the executable during
linking. So the only way to mitigate this is to load valgrind at a higher
memory address.

Attached is a proof-of-principle patch for amd64-linux that demonstrates that
support for high load addresses can be implemented with only a few changes to
the code. The patch sets the load address to 0x80000000 (2GiB). Currently,
there are two caveats:

 1. valgrind has to be configured with CFLAGS='-mcmodel=large'
CXXFLAGS='-mcmodel=large'
 2. the call to __gnu_cxx::__freeres() in vg_preloaded.c for some reason jumps
to a non-code location,
    which crashes C++ programs during exit (it seems to miscalculate the
argument to a callq instruction).

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

Reply via email to