-
Notifications
You must be signed in to change notification settings - Fork 113
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
[UR][layer] Add exception sanitizer layer #2216
base: main
Are you sure you want to change the base?
Conversation
2e932e0
to
c1be939
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I suspect this was never tested :D So might be good to enable this in CI for CTS.
c1be939
to
1cf0578
Compare
f26923e
to
375ab46
Compare
Thanks have done so. I'm not sure what the failures are related to. |
375ab46
to
f5ac85b
Compare
ebc7760
to
942e682
Compare
Add basic exception sanitizer layer that will call std::abort if an exception is thrown.
And initialize UR_ENABLE_EXCEPTION_SANITIZER to OFF.
Add compile time macro and also fix typos in ur_lib.hpp.
Don't allow UR_CHECK_ERROR to be called outside of a try block.
942e682
to
dbe486a
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, thanks for improving our code quality
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So the missing part here is actually enabling the layer in the CTS environment setup, something along the lines of this:
diff --git a/test/conformance/source/environment.cpp b/test/conformance/source/environment.cpp
index 006ea09b..737d26d2 100644
--- a/test/conformance/source/environment.cpp
+++ b/test/conformance/source/environment.cpp
@@ -90,6 +90,14 @@ uur::PlatformEnvironment::PlatformEnvironment(int argc, char **argv)
error = "Failed to enable validation layer";
return;
}
+#ifdef UR_ENABLE_EXCEPTION_SANITIZER
+ if (urLoaderConfigEnableLayer(config, "UR_LAYER_EXCEPTION_SANITIZER") !=
+ UR_RESULT_SUCCESS) {
+ urLoaderConfigRelease(config);
+ error = "Failed to enable exception sanitizer layer";
+ return;
+ }
+#endif
} else {
error = "Failed to create loader config handle";
return;
CMakeLists.txt
Outdated
@@ -43,6 +43,7 @@ option(UR_USE_TSAN "enable ThreadSanitizer" OFF) | |||
option(UR_ENABLE_TRACING "enable api tracing through xpti" OFF) | |||
option(UR_ENABLE_SANITIZER "enable device sanitizer" ON) | |||
option(UR_ENABLE_SYMBOLIZER "enable symoblizer for sanitizer" OFF) | |||
option(UR_ENABLE_EXCEPTION_SANITIZER "enable exception sanitizer" OFF) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not sure we need a separate option, we could always enable this as part of UR_DEVELOPER_MODE
since that's enabled in CI.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks, have removed.
Co-authored-by: Kenneth Benzie (Benie) <k.benzie83@gmail.com>
Co-authored-by: Kenneth Benzie (Benie) <k.benzie83@gmail.com>
Interesting, how was the layer working here without this call? |
The init function of all layers gets called unconditionally, and the layer themselves need to check whether they are on the enabled list. |
Aha thanks @pbalcer that explains it |
Have updated. Should be good to go. |
bb96bde
to
56287f5
Compare
Add basic exception sanitizer layer that will call std::abort if an exception is thrown. This layer can be used to make sure an adapter isn't throwing, which is prohibited for a C interface. The layer can be enabled by building with the option
-DUR_ENABLE_EXCEPTION_SANITIZER=ON