Created attachment 122258 [details] Program with large BSS. VERSION Valgrind-3.16.0.GIT SUMMARY I get this error message: valgrind: mmap(0x602000, 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 could indicate a solution to this problem by suggesting the following linker option: -Wl,-Ttext-segment=0x68000000 STEPS TO REPRODUCE 1. gcc -o large large.c 2. valgrind ./large 3. gcc -Wl,-Ttext-segment=0x68000000 -o large large.c 4. valgrind ./large OBSERVED RESULT valgrind: mmap(0x602000, 2147483648) failed in UME with error 22 (Invalid argument). valgrind: this can be caused by executables with very large text, data or bss segments. EXPECTED RESULT A message suggesting usage of the above mentioned linker option. SOFTWARE/OS VERSIONS Linux: CentOS Linux release 7.5.1804 (Core) ADDITIONAL INFORMATION This has been discussed in threads: https://sourceforge.net/p/valgrind/mailman/message/36140514/ https://sourceforge.net/p/valgrind/mailman/message/36744406/
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?