| Summary: | Valgrind does not provide a solution in the error message when an mmap error is detected. | ||
|---|---|---|---|
| Product: | [Developer tools] valgrind | Reporter: | João M. S. Silva <joao.m.santos.silva> |
| Component: | memcheck | Assignee: | Julian Seward <jseward> |
| Status: | REPORTED --- | ||
| Severity: | minor | ||
| Priority: | NOR | ||
| Version First Reported In: | unspecified | ||
| Target Milestone: | --- | ||
| Platform: | Compiled Sources | ||
| OS: | Linux | ||
| Latest Commit: | Version Fixed/Implemented In: | ||
| Sentry Crash Report: | |||
| Attachments: | Program with large BSS. | ||
|
Description
João M. S. Silva
2019-08-20 13:31:54 UTC
Hmm, maybe it's time to change the tool load address .. again. I found out that I could solve a similar issue with Address Sanitizer by building with -fPIE, -pie and -shared, iirc. I just made a patch which changes the error message to this: valgrind: mmap(0x405000, 2147483648) failed in UME with error 22 (Invalid argument). valgrind: This can be caused by executables with very large text, data or bss segments. valgrind: You might be able to work around this by changing the default load address on your executable. valgrind: You can do that by adding the following flag to your gcc/g++ link command: valgrind: -Wl,-Ttext-segment=0x68000000 Maybe I should add text about PIE, etc, as an alternative solution? Can you suggest some suitable text? I'm thinking of the following, but I don't know the *exact* details of
what to suggest to build a PIE. Can you fill those in?
mmap(0x405000, 2147483648) failed in UME with error 22 (Invalid argument).
This can be caused by executables with very large text, data or bss segments.
The underlying problem is that some part of your executable wants to be loaded
at an address which conflicts with where Valgrind's tool executable wants to
be loaded. There are two possible ways you could try to work around this:
* by changing the default load address on your executable. You can do that by
adding the following flag to your gcc/g++ link command:
-Wl,-Ttext-segment=0x68000000
* by making your executable be position-independent, so it can be loaded
anywhere. You can do that by [FILL THIS BIT IN]
I'm not sure it also solves it for Valgrind because Valgrind had an additional issue with Ada elaboration / stack unwinding or so (don't understand enough about it) that I could never solve. Anyway, it could be: * by making your executable be position-independent, so it can be loaded anywhere. You can do that by compiling with switch -fPIE and linking with switch -pie. You should also pass -shared to the binder, but I believe this is only applicable to Ada code? |