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

Crash with memory sanitizer on Linux 6.5.0-25 #85013

Closed
yamam opened this issue Mar 13, 2024 · 5 comments
Closed

Crash with memory sanitizer on Linux 6.5.0-25 #85013

yamam opened this issue Mar 13, 2024 · 5 comments
Labels

Comments

@yamam
Copy link

yamam commented Mar 13, 2024

Reproduction Steps:
The following commands reproduce with more than 50% probability.
$ echo 'int main(void) {return 0;}'|clang -fsanitize=memory -fPIE -pie -x c -;./a.out
FATAL: Code 0x62437d12e410 is out of application range. 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'.
==10691==Process memory map follows:

Environment:
Linux PC-20240312A024 6.5.0-25-generic #25~22.04.1-Ubuntu SMP PREEMPT_DYNAMIC Tue Feb 20 16:09:15 UTC 2 x86_64 x86_64
x86_64 GNU/Linux
Ubuntu clang version 14.0.0-1ubuntu1.1
Target: x86_64-pc-linux-gnu
Thread model: posix
InstalledDir: /usr/bin

It does not occur when reverting to 6.5.0-21-generic

@DimitryAndric
Copy link
Collaborator

A possibly related issue is https://bugs.launchpad.net/ubuntu/+source/linux/+bug/2056762, since this is about the Ubuntu HWE kernel, and the problem I saw was with ThreadSanitizer falling over, due to "unexpected memory mapping".

I am suspecting that Ubuntu's 6.5.0-21 -> 6.5.0-25 update changed something in the way memory mappings work (for ASLR or otherwise), that trips up some internal assertions in the sanitizers.

@DimitryAndric
Copy link
Collaborator

Also, google/sanitizers#1716, which seems to indicate a kernel change to be the culprit.

@yamam
Copy link
Author

yamam commented May 9, 2024

I have confirmed that it does not occur on Ubuntu 24.04.

$ clang -v
Ubuntu clang version 18.1.3 (1)
Target: x86_64-pc-linux-gnu
Thread model: posix
InstalledDir: /usr/bin
Found candidate GCC installation: /usr/bin/../lib/gcc/x86_64-linux-gnu/13
Selected GCC installation: /usr/bin/../lib/gcc/x86_64-linux-gnu/13
Candidate multilib: .;@m64
Candidate multilib: 32;@m32
Candidate multilib: x32;@mx32
Selected multilib: .;@m64
$ uname -a
Linux masanari-VirtualBox 6.8.0-31-generic #31-Ubuntu SMP PREEMPT_DYNAMIC Sat Apr 20 00:40:06 UTC 2024 x86_64 x86_64 x86_64 GNU/Linux

The following combination occurs:
Running an executable file generated on Ubuntu 22.04 (clang 14.0.0-1ubuntu1.1) on Ubuntu 24.04 (6.8.0-31-generic).

The following combination does not occur:
Running an executable file generated on Ubuntu 24.04 (clang 18.1.3 (1)) on Ubuntu 22.04 (6.5.0-28-generic).

@DimitryAndric
Copy link
Collaborator

I have confirmed that it does not occur on Ubuntu 24.04.
...
The following combination does not occur: Running an executable file generated on Ubuntu 24.04 (clang 18.1.3 (1)) on Ubuntu 22.04 (6.5.0-28-generic).

This is because a similar fix as for TSan got merged into llvm-project's 18.x branch:
c2a5703

I'm not sure at what version that was, but apparently 18.1.3 has it! :)

@yamam
Copy link
Author

yamam commented May 10, 2024

Thank you. Since the issue seems to have been resolved, I will close it.

@yamam yamam closed this as completed May 10, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants