FATAL: MemorySanitizer can not mmap the shadow memory.

404 views
Skip to first unread message

Jeffrey Walton

unread,
Feb 27, 2016, 12:01:16 AM2/27/16
to memory-s...@googlegroups.com
Hi Everyone,

I'm experiencing the following.

FATAL: Code below application range: 0x56195775bd90 < 0x600000000000.
Non-PIE build?
FATAL: MemorySanitizer can not mmap the shadow memory.
FATAL: Make sure to compile with -fPIE and to link with -pie.
FATAL: Disabling ASLR is known to cause this error.

The makefile's CXXFLAGS includes -fPIC for all object files. The
makefile's CXXFLAGS includes -pie for the executable program. So I
think the relocation requirements are covered. (According to the GCC
folks, -fPIC can be used anywhere -fPIE is required. I'm making the
leap the same applies to Clang).

The only out-of-the-ordinary thing I have noticed is the machine is a
desktop with 16GB of memory, and it produces the following in syslog.
I'm not used to seeing it because I don't have machines with this much
memory.

[ 0.000000] total RAM covered: 16320M
[ 0.000000] Found optimal setting for mtrr clean up
[ 0.000000] gran_size: 64K chunk_size: 64M
num_reg: 9 lose cover RAM: 0G
[ 0.000000] New variable MTRRs
[ 0.000000] reg 0, base: 0GB, range: 2GB, type WB
[ 0.000000] reg 1, base: 2GB, range: 1GB, type WB
[ 0.000000] reg 2, base: 3GB, range: 512MB, type WB
[ 0.000000] reg 3, base: 3536MB, range: 16MB, type UC
[ 0.000000] reg 4, base: 3552MB, range: 32MB, type UC
[ 0.000000] reg 5, base: 4GB, range: 4GB, type WB
[ 0.000000] reg 6, base: 8GB, range: 8GB, type WB
[ 0.000000] reg 7, base: 16GB, range: 512MB, type WB
[ 0.000000] reg 8, base: 16880MB, range: 16MB, type UC

Any ideas what I should do?

Thanks in advance.

Konstantin Serebryany

unread,
Feb 27, 2016, 12:06:14 AM2/27/16
to memory-s...@googlegroups.com
Hi Jeffrey, 

Are you using the fresh clang from trunk? 
What is your OS version? 
Do simple tests (e.g. this one) work for you?

--kcc 


--
You received this message because you are subscribed to the Google Groups "memory-sanitizer" group.
To unsubscribe from this group and stop receiving emails from it, send an email to memory-sanitiz...@googlegroups.com.
To post to this group, send email to memory-s...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/memory-sanitizer/CAH8yC8kARnFY52FRXx-2opo82vuzCXF-UnVDEDHj1ESFj5oCbA%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

nolo...@gmail.com

unread,
Feb 27, 2016, 11:27:30 AM2/27/16
to memory-sanitizer

Are you using the fresh clang from trunk? 

No. Its provided by Ubuntu via GCC 4.8.

Do you recommend Debian/Ubuntu pick up any patches in particular? If so, I will file the bug reports.
 
What is your OS version? 

Oh man... What a rookie mistake:

$ uname -a
Linux qotom 3.19.0-51-generic #57~14.04.1-Ubuntu SMP Fri Feb 19 14:36:55 UTC 2016 x86_64 x86_64 x86_64 GNU/Linux

$ lsb_release -a
No LSB modules are available.
Distributor ID:    Ubuntu
Description:    Ubuntu 14.04.4 LTS
Release:    14.04
Codename:    trusty

$ gcc --version
gcc (Ubuntu 4.8.4-2ubuntu1~14.04.1) 4.8.4
Copyright (C) 2013 Free Software Foundation, Inc.
...
 
Do simple tests (e.g. this one) work for you?

Thanks, let me try it.

Jeff

nolo...@gmail.com

unread,
Feb 27, 2016, 11:46:55 AM2/27/16
to memory-sanitizer

 
What is your OS version? 

Oh man... What a rookie mistake:

$ uname -a
Linux qotom 3.19.0-51-generic #57~14.04.1-Ubuntu SMP Fri Feb 19 14:36:55 UTC 2016 x86_64 x86_64 x86_64 GNU/Linux

$ lsb_release -a
No LSB modules are available.
Distributor ID:    Ubuntu
Description:    Ubuntu 14.04.4 LTS
Release:    14.04
Codename:    trusty

$ gcc --version
gcc (Ubuntu 4.8.4-2ubuntu1~14.04.1) 4.8.4
Copyright (C) 2013 Free Software Foundation, Inc.
...

Arg... GCC 4.8 does not support Msan. Here's the real information:

  $ clang --version
  Ubuntu clang version 3.4-1ubuntu3 (tags/RELEASE_34/final) (based on LLVM 3.4)
  Target: x86_64-pc-linux-gnu
  Thread model: posix

Jeff

nolo...@gmail.com

unread,
Feb 27, 2016, 12:30:05 PM2/27/16
to memory-sanitizer

Do simple tests (e.g. this one) work for you?


I can duplicate the issue with the simple test. I can also duplicate with explicit use of -fPIE and -pie (avoiding -fPIC).

I guess the next step is to either (1) find a distro with a newer version of Msan; or (2) build Clang from sources? What do you recommend?

Jeff

$ cat msan.cc
#include <stdlib.h>
int main(int argc, char **argv) {
  int x;
  int *volatile p = &x;
  return *p;
}
$ clang -g -fPIC -fsanitize=memory msan.cc -c -o msan.o
$ clang -g -pie -fsanitize=memory msan.o -o msan.exe
$ ./msan.exe
FATAL: Code below application range: 0x55c5bb5e6ed0 < 0x600000000000. Non-PIE build?

FATAL: MemorySanitizer can not mmap the shadow memory.
FATAL: Make sure to compile with -fPIE and to link with -pie.
FATAL: Disabling ASLR is known to cause this error.
FATAL: If running under GDB, try 'set disable-randomization off'.
==10128==Process memory map follows:
    0x55c5bb580000-0x55c5bb60a000    /home/msan.exe
    0x55c5bb809000-0x55c5bb80a000    /home/msan.exe
    0x55c5bb80a000-0x55c5bb80b000    /home/msan.exe
    ...
 

Konstantin Serebryany

unread,
Feb 27, 2016, 12:57:51 PM2/27/16
to memory-s...@googlegroups.com
On Sat, Feb 27, 2016 at 9:30 AM, <nolo...@gmail.com> wrote:

Do simple tests (e.g. this one) work for you?


I can duplicate the issue with the simple test. I can also duplicate with explicit use of -fPIE and -pie (avoiding -fPIC).

I guess the next step is to either (1) find a distro with a newer version of Msan; or (2) build Clang from sources? What do you recommend?


Yes, just grab the fresh clang/llvm from sources. 
Your distro is fine, we also use Ubuntu 14.04. 


 
Jeff

$ cat msan.cc
#include <stdlib.h>
int main(int argc, char **argv) {
  int x;
  int *volatile p = &x;
  return *p;
}
$ clang -g -fPIC -fsanitize=memory msan.cc -c -o msan.o
$ clang -g -pie -fsanitize=memory msan.o -o msan.exe
$ ./msan.exe
FATAL: Code below application range: 0x55c5bb5e6ed0 < 0x600000000000. Non-PIE build?
FATAL: MemorySanitizer can not mmap the shadow memory.
FATAL: Make sure to compile with -fPIE and to link with -pie.
FATAL: Disabling ASLR is known to cause this error.
FATAL: If running under GDB, try 'set disable-randomization off'.
==10128==Process memory map follows:
    0x55c5bb580000-0x55c5bb60a000    /home/msan.exe
    0x55c5bb809000-0x55c5bb80a000    /home/msan.exe
    0x55c5bb80a000-0x55c5bb80b000    /home/msan.exe
    ...
 

--
You received this message because you are subscribed to the Google Groups "memory-sanitizer" group.
To unsubscribe from this group and stop receiving emails from it, send an email to memory-sanitiz...@googlegroups.com.
To post to this group, send email to memory-s...@googlegroups.com.

nolo...@gmail.com

unread,
Feb 27, 2016, 6:08:11 PM2/27/16
to memory-sanitizer

I guess the next step is to either (1) find a distro with a newer version of Msan; or (2) build Clang from sources? What do you recommend?


Yes, just grab the fresh clang/llvm from sources. 
Your distro is fine, we also use Ubuntu 14.04.

OK, so I jumped over to Debian 8 which supplies Clang 3.5. Things worked as expected, but the Debian machine only has 4GB of memory.

I can continue to troubleshoot in case the issue is a corner case due to the amount of RAM.

What would you like me to do?

Jeff

Konstantin Serebryany

unread,
Feb 28, 2016, 1:11:28 AM2/28/16
to memory-s...@googlegroups.com
3.5 is pretty old too, if anything breaks we will not be able to help. 
Get back to Ubuntu 14.04 and build clang from source. It's easy. 
You can find the exact build steps e.g. here: https://github.com/google/libfuzzer-bot/blob/master/common/make_llvm_archive.sh





 
Jeff

--
You received this message because you are subscribed to the Google Groups "memory-sanitizer" group.
To unsubscribe from this group and stop receiving emails from it, send an email to memory-sanitiz...@googlegroups.com.
To post to this group, send email to memory-s...@googlegroups.com.

nolo...@gmail.com

unread,
Feb 28, 2016, 5:51:35 AM2/28/16
to memory-sanitizer

I can continue to troubleshoot in case the issue is a corner case due to the amount of RAM.

What would you like me to do?

3.5 is pretty old too, if anything breaks we will not be able to help. 
Get back to Ubuntu 14.04 and build clang from source. It's easy. 
You can find the exact build steps e.g. here: https://github.com/google/libfuzzer-bot/blob/master/common/make_llvm_archive.sh

Perfect, thanks.

The offer is on the table since you've been very helpful to me.

Jeff

Evgenii Stepanov

unread,
Feb 29, 2016, 4:17:53 PM2/29/16
to memory-s...@googlegroups.com
This could be caused by disabled ASLR, you could try
sysctl -w kernel.randomize_va_space=0
and the same with =1.
Updating clang sounds like a good idea anyway, and it will definitely
fix this problem.
> --
> You received this message because you are subscribed to the Google Groups
> "memory-sanitizer" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to memory-sanitiz...@googlegroups.com.
> To post to this group, send email to memory-s...@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/memory-sanitizer/4da5f685-c3c8-42c5-b0ff-a0cbe1111023%40googlegroups.com.
Reply all
Reply to author
Forward
0 new messages