Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Linux 4.1: FATAL: ThreadSanitizer: unexpected memory mapping #503

Closed
ramosian-glider opened this issue Sep 1, 2015 · 13 comments
Closed

Comments

@ramosian-glider
Copy link
Member

Originally reported on Google Code with ID 96

With Linux 4.1 and gcc 4.9 or 5.2 I get this error:

$ echo 'void main(void){}' | gcc -pie -fPIE -fsanitize=thread -xc - && ./a.out
FATAL: ThreadSanitizer: unexpected memory mapping 0x55d400945000-0x55d40094600

It seems that this commit (thanks to Ben Hutchings for finding it) is change is the
root of the problem: 
https://git.kernel.org/linus/d1fd836dcf00d2028c700c7e44d2c23404062c90

Related: http://bugs.debian.org/796246

Reported by jrobert.pro on 2015-08-21 12:33:55

@ramosian-glider
Copy link
Member Author

The same bug for MSan:
https://llvm.org/bugs/show_bug.cgi?id=24155

I thought TSan would not be affected by this. Is that a GCC vs Clang difference?

Reported by eugenis@google.com on 2015-08-21 19:03:25

@ramosian-glider
Copy link
Member Author

This bug in the GCC bugtracker: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=67308

Reported by jrobert.pro on 2015-08-22 14:38:03

@ramosian-glider
Copy link
Member Author

May also be relevant for ASan.

Reported by tetra2005x on 2015-08-24 06:08:41

@dvyukov
Copy link
Contributor

dvyukov commented Sep 5, 2015

Latest tsan runtime supports non-pie binaries. Non-pie tsan binaries should work with 4.1, right?

@jeromerobert
Copy link

Yes they do (tested with gcc 5.2 and Linux 4.2). So I guess this bug is now just about the documentation.

@milianw
Copy link

milianw commented Oct 3, 2015

Hey all,

Qt builds all its code in PIE/PIC mode. Thus this bug prevents it from being used on all of the Qt ecosystem. I don't think it's just about fixing the documentation, I hope you guys can find a way to make the sanitizers work with PIE/PIC binaries.

If anyone has a patch for me to try out, I'd gladly do that.

Thanks for the Sanitizers!

@dvyukov
Copy link
Contributor

dvyukov commented Dec 1, 2015

Qt builds all its code in PIE/PIC mode. Thus this bug prevents it from being used on all of the Qt ecosystem.

FWIW this does not prevent tsan to be used with tsan. Qt does not build its code with -fsanitize-thread either. Whoever does a separate tsan build can also remove -pie.

@gpakosz
Copy link

gpakosz commented Jun 9, 2016

Why is this issue closed?

As far as I understand, the current status is that TSAN doesn't need -fpie anymore which defines a workaround for newer Linux kernels: don't compile with -fpie.

But that doesn't solve the Linux 4.1 + TSAN + -fpie equation.

Did I get it right?

@dvyukov
Copy link
Contributor

dvyukov commented Jun 9, 2016

@gpakosz This is issue is not closed.
It's "misc/cgo/testsanitizers: fails on Ubuntu 16.10" that is closed.

@gpakosz
Copy link

gpakosz commented Jun 9, 2016

Damn you're so right. I'm sorry I mixed up statuses

@lilianmoraru
Copy link

This error usually appears when people forget to export LD_PRELOAD before running the application.
Example on Ubuntu, 64-bit, gcc 5:

export LD_PRELOAD="/usr/lib/gcc/x86_64-linux-gnu/5/libtsan.so"
./binary # running the application compiled with tsan

Hope this helps.

gurgenh added a commit to cloudendpoints/esp that referenced this issue Aug 22, 2016
Travis upgraded the trusty image that tests use and it broke our TSAN
tests. TSAN does not work for pie binaries on the upgraded OS. See
google/sanitizers#503
The fix is to use gcc-5 and non-pie binaries.

Change-Id: I9b972f1c08fb7408d5bcc54b403660c1255a11d5
@dvyukov
Copy link
Contributor

dvyukov commented Sep 26, 2016

@lilianmoraru You don't need to LD_PRELOAD tsan runtime. That's wrong and is not guaranteed to work.

@dvyukov
Copy link
Contributor

dvyukov commented Sep 26, 2016

@dvyukov dvyukov closed this as completed Sep 26, 2016
facebook-github-bot pushed a commit to facebook/mysql-5.6 that referenced this issue May 11, 2017
Summary:
Fixing the following issues when building with gcc5.x:
- TSAN: no longer requires to be built with -pie. Based on
  google/sanitizers#503
- UBSAN: gcc5 introduced a new vptr santizer in UBSAN, which will generate some
  false alarms about "undefined reference" during linking. Suppressing vptr
  sanitizer.
- Valgrind: Added new suppression rules
- ASAN: (suppression added in tools)

Reviewed By: gunnarku

Differential Revision: D5039367

fbshipit-source-id: 00ab2ca
IslamAbdelRahman pushed a commit to IslamAbdelRahman/mysql-5.6 that referenced this issue May 31, 2017
Summary:
Fixing the following issues when building with gcc5.x:
- TSAN: no longer requires to be built with -pie. Based on
  google/sanitizers#503
- UBSAN: gcc5 introduced a new vptr santizer in UBSAN, which will generate some
  false alarms about "undefined reference" during linking. Suppressing vptr
  sanitizer.
- Valgrind: Added new suppression rules
- ASAN: (suppression added in tools)

Test Plan: manual build and sandcastle

Reviewers: gunnarku

Reviewed By: gunnarku

Subscribers: webscalesql-eng@fb.com

Differential Revision: https://phabricator.intern.facebook.com/D5039367

Tasks: 18077031, 17217920, 18077885, 17553023

Signature: t1:5039367:1494528829:2a650d7e39032bf3ce5cb4180617fdbc90adf359
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

6 participants