ThreadSanitizer: unexpected memory mapping with 6.5.0-25.25~22.04.1
Affects | Status | Importance | Assigned to | Milestone | |
---|---|---|---|---|---|
linux (Ubuntu) |
Confirmed
|
Undecided
|
Unassigned | ||
Mantic |
Won't Fix
|
Undecided
|
Unassigned |
Bug Description
We updated a number of (amd64) machines from linux-image-
FATAL: ThreadSanitizer: unexpected memory mapping 0x5c4dc2bcd000-
Reverting the kernel back to 6.5.0-21.21~22.04.1 and rebooting makes the same executables work again.
There are a few older bugs including https:/
A very small program, lifted from https:/
$ cat simple-race.c
#include <pthread.h>
#include <stdio.h>
int Global;
void *Thread1(void *x) {
Global++;
return NULL;
}
void *Thread2(void *x) {
Global--;
return NULL;
}
int main() {
pthread_t t[2];
pthread_
pthread_
pthread_
pthread_
}
$ cc -fsanitize=thread -fPIE -pie -g simple-race.c -o simple-race
$ ./simple-race
FATAL: ThreadSanitizer: unexpected memory mapping 0x5d161227c000-
$ uname -a
Linux buildhost 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
When running that exact same binary, on the same machine, but with linux 6.5.0-21:
$ ./simple-race
==================
WARNING: ThreadSanitizer: data race (pid=19373)
Read of size 4 at 0x560964a2d014 by thread T2:
#0 Thread2 /home/lxc-
Previous write of size 4 at 0x560964a2d014 by thread T1:
#0 Thread1 /home/lxc-
Location is global 'Global' of size 4 at 0x560964a2d014 (simple-
Thread T2 (tid=19376, running) created by main thread at:
#0 pthread_create ../../.
#1 main /home/lxc-
Thread T1 (tid=19375, finished) created by main thread at:
#0 pthread_create ../../.
#1 main /home/lxc-
SUMMARY: ThreadSanitizer: data race /home/lxc-
==================
ThreadSanitizer: reported 1 warnings
$ uname -a
Linux buildhost 6.5.0-21-generic #21~22.04.1-Ubuntu SMP PREEMPT_DYNAMIC Fri Feb 9 13:32:52 UTC 2 x86_64 x86_64 x86_64 GNU/Linux
Note that similar to the older gcc and upstream sanitizer bugs, this problem may be caused by some kernel API now returning a slightly different result, so it could be debatable whether the issue should be fixed in ThreadSanitizer, or in the kernel itself.