mirror of
https://github.com/odin-lang/Odin.git
synced 2026-08-05 05:38:31 +00:00
Don't free virtual memory when ThreadSanitizer is active
This is a workaround for a lack of an ability to tell TSan that it should clear any state it has about certain memory ranges to prevent false positives.
This commit is contained in:
@@ -65,7 +65,19 @@ allocate_virtual_memory_aligned :: proc "contextless" (size: int, alignment: int
|
||||
Free virtual memory allocated by any of the `allocate_*` procs.
|
||||
*/
|
||||
free_virtual_memory :: proc "contextless" (ptr: rawptr, size: int) {
|
||||
_free_virtual_memory(ptr, size)
|
||||
// TODO: There is currently no good way to tell ThreadSanitizer that we're
|
||||
// done with a region of memory and to clear any information it has about
|
||||
// it, so that when it's enabled, we simply do not release any memory back
|
||||
// to the operating system.
|
||||
//
|
||||
// This prevents all false positive warnings when one thread inevitably
|
||||
// gives up some of its memory that is then re-assigned to a different
|
||||
// thread by the operating system.
|
||||
//
|
||||
// This is a workaround for the time being.
|
||||
when .Thread not_in ODIN_SANITIZER_FLAGS {
|
||||
_free_virtual_memory(ptr, size)
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
|
||||
Reference in New Issue
Block a user