Bug 67308 - FATAL: ThreadSanitizer: unexpected memory mapping
Summary: FATAL: ThreadSanitizer: unexpected memory mapping
Status: RESOLVED FIXED
Alias: None
Product: gcc
Classification: Unclassified
Component: sanitizer (show other bugs)
Version: 5.2.1
: P3 normal
Target Milestone: ---
Assignee: Not yet assigned to anyone
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2015-08-21 14:45 UTC by Matthias Klose
Modified: 2018-04-20 01:19 UTC (History)
5 users (show)

See Also:
Host:
Target:
Build:
Known to work:
Known to fail:
Last reconfirmed:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Matthias Klose 2015-08-21 14:45:42 UTC
[forwarded from https://bugs.debian.org/796246]

seen on the gcc-5-branch.

$ uname -r
4.1.0-3-generic
$ echo 'void main(void){}' | gcc -pie -fPIE -fsanitize=thread -xc - -ltsan && ./a.out
FATAL: ThreadSanitizer: unexpected memory mapping 0x555caf24a000-0x555caf24b000

"""
There was an intentional change in the kernel that causes PIEs to be
loaded in a different address range:

https://git.kernel.org/linus/d1fd836dcf00d2028c700c7e44d2c23404062c90

I think ThreadSanitizer is just going to have to learn about this.
"""
Comment 1 Jerome Robert 2015-08-22 14:35:25 UTC
Reported on the ThreadSanitizer bugtracker:
https://code.google.com/p/thread-sanitizer/issues/detail?id=96
Comment 2 Jerome Robert 2015-10-02 20:06:22 UTC
ThreadSanitizer moved to github so the bug is now:
https://github.com/google/sanitizers/issues/503
Comment 3 Jerome Robert 2015-10-02 20:49:49 UTC
It looks like PIE is no longer needed (at least with gcc 5.2).

echo 'void main(void){}' | gcc -fsanitize=thread -xc - -ltsan && ./a.out

just work fine.
Comment 4 Paulo R. Panhoto 2016-07-07 18:09:21 UTC
I've got the same problem with GCC 4.8.5 and that release doesn't allow me to exclude the -pie flag. 

gcc: error: -fsanitize=thread linking must be done with -pie or -shared
Comment 5 Jerome Robert 2017-02-14 15:00:37 UTC
I did not test my self but this is supposed to be fixed in trunk (and not backported to 6.x):

https://gcc.gnu.org/viewcvs/gcc?view=revision&revision=241977
http://llvm.org/viewvc/llvm-project?view=revision&revision=282152
Comment 6 Marek Polacek 2018-04-20 01:19:46 UTC
Fixed for GCC 7.