You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
We have leaks detected by asan (well lsan really) in our vulkan tests. For now I'm disabling vulkan from the asan bot I'm bringing up. I'm not sure if this is something we can fix, at least for swiftshader, or whether we just need to figure out the right sanitizer suppressions.
So long as IREE_ASSERT_OK is tied to gtest it's fine to wrap in an iree::Status - if we wanted to switch to a C unit testing framework then we'd want to make it safe.
though we may want to do some && trickery to ensure they aren't used later; this would be bad:
iree_status_tstatus= ...;
IREE_ASSERT_OK(status);
do_something(status); // status not valid here
All for making it harder to leak them in tests in the normal path --- leaks in failure cases are fine (as barely any test code is expected to gracefully fail).
Yeah, the status leaks came up when I broke dlopen by passing the wrong flags - I finally saw accurate asan stacks, but for status code and not Vulkan code :P
Editing the Vulkan Loader code linked above helped me get useful reports from ASAN, which all pointed to leaks throughout libnvidia-glcore.so on my machine. When I switch to using SwiftShader, I see no leaks in IREE's Vulkan tests.
Possible next steps:
Debug inside our Docker images, with dlopen/dlclose changes to IREE's code and the Vulkan Loader
Update our SwiftShader build to a more recent commit - maybe there were leaks that were fixed
Investigate ASAN suppressions (these might also need the dlopen/dlclose changes?)
Tracer caught signal 11: addr=0x0 pc=0x50c558 sp=0x7fb28fdffd10
==50923==LeakSanitizer has encountered a fatal error.
==50923==HINT: For debugging, try setting environment variable LSAN_OPTIONS=verbosity=1:log_threads=1
==50923==HINT: LeakSanitizer does not work under ptrace (strace, gdb, etc)
Next step is to try that debugging hint (LSAN_OPTIONS), possibly with dlclose() disabled in IREE code and in libvulkan.so.1 (the Vulkan Loader). I wasn't able to repro those crashes on my local machine, so we might need to debug under Docker.
Activity
ScottTodd commentedon Mar 14, 2022
I found a few issues here, but haven't yet figured out the right solutions.
IREE_ASSERT_OKleaksiree_status_tstructures for non-ok statusesThe code for that lives in https://github.com/google/iree/blob/main/iree/testing/status_matchers.h and was mostly written back before the C++ -> C HAL rewrite. Removing the C++
iree::Statusclass and updating the test macros to be leak free and built on top of the C API seems like good cleanup.https://github.com/google/iree/blob/6258b50051e4aeb97ebc10f28e9e240760366c6f/iree/hal/vulkan/dynamic_symbols_test.cc#L43-L45
dynamic library loading (dlopen/dlsym/dlclose) interferes with ASAN reporting and symbolization
We open
libvulkan.so, but ASAN has trouble understanding that and constructing a useful leak report. It seems like ASAN needs loaded libraries to remain open at process exit: see https://stackoverflow.com/questions/44627258/addresssanitizer-and-loading-of-dynamic-libraries-at-runtime-unknown-module and various issues on GitHub. Without any changes, I see all these<unknown module>addresses in the ASAN report:I tried some variations on our
dlopen()flags (mainly addingRTLD_NODELETE) and removing our call todlclose(), but I still can't get useful data from ASAN.https://github.com/google/iree/blob/6258b50051e4aeb97ebc10f28e9e240760366c6f/iree/base/internal/dynamic_library_posix.c#L176-L179
https://github.com/google/iree/blob/6258b50051e4aeb97ebc10f28e9e240760366c6f/iree/base/internal/dynamic_library_posix.c#L234-L250
benvanik commentedon Mar 14, 2022
So long as IREE_ASSERT_OK is tied to gtest it's fine to wrap in an iree::Status - if we wanted to switch to a C unit testing framework then we'd want to make it safe.
We could try making the macros something like:
or
though we may want to do some
&&trickery to ensure they aren't used later; this would be bad:All for making it harder to leak them in tests in the normal path --- leaks in failure cases are fine (as barely any test code is expected to gracefully fail).
ScottTodd commentedon Mar 14, 2022
Yeah, the status leaks came up when I broke dlopen by passing the wrong flags - I finally saw accurate asan stacks, but for status code and not Vulkan code :P
Any dlopen()/dlclose() tweaks may need to reach into the Vulkan loader as well: https://github.com/KhronosGroup/Vulkan-Loader/blob/8198bebc7fe31c3da54b1dfacbb92e8697646701/loader/vk_loader_platform.h#L238-L257. I'm also trying some LD_PRELOAD tricks but no luck so far.
ScottTodd commentedon Mar 14, 2022
Editing the Vulkan Loader code linked above helped me get useful reports from ASAN, which all pointed to leaks throughout
libnvidia-glcore.soon my machine. When I switch to using SwiftShader, I see no leaks in IREE's Vulkan tests.Possible next steps:
Include most Vulkan tests in ASan build. (#8489)
ScottTodd commentedon Mar 15, 2022
Updating SwiftShader helped!
Most Vulkan tests are fixed + enabled under ASan now.
These remain:
https://github.com/google/iree/blob/bcb6199e19d5a6320397258a8028fc5ec3459d0d/build_tools/kokoro/gcp_ubuntu/cmake/linux/x86-swiftshader-asan/build.sh#L105-L111
with logs like
(full logs here)
Next step is to try that debugging hint (
LSAN_OPTIONS), possibly withdlclose()disabled in IREE code and inlibvulkan.so.1(the Vulkan Loader). I wasn't able to repro those crashes on my local machine, so we might need to debug under Docker.ScottTodd commentedon Aug 10, 2022
Still seeing a few ASan+Vulkan tests fail occasionally with that LeakSanitizer crash
e2e/models/mnist_fake_weights.mlir: https://github.com/iree-org/iree/runs/7768946982?check_suite_focus=truee2e/models/fragment_000.mlir.test: #10004Seems like the failures are flakes, since they keep popping up one at a time?
Exclude more tests from ASan test configuration. (#10281)
Disable iree/tests/e2e/regression/globals.mlir.test under ASan. (#10892)
Disable iree/tests/e2e/regression/globals.mlir.test under ASan. (iree…