Skip to content

Conversation

@AllanZyne
Copy link
Contributor

@AllanZyne AllanZyne commented Oct 23, 2024

LLVM: intel/llvm#15843
code refactoring for implementing the msan layer

@AllanZyne AllanZyne requested a review from a team as a code owner October 23, 2024 08:29
@github-actions github-actions bot added loader Loader related feature/bug sanitizer Sanitizer layer issues/changes/specification labels Oct 23, 2024
@AllanZyne AllanZyne changed the title [DeviceAsan][NFC] Code Restructure [DeviceSanitizer][NFC] Code Restructure Oct 23, 2024
@AllanZyne AllanZyne changed the title [DeviceSanitizer][NFC] Code Restructure [DeviceASAN][NFC] Code Restructure Oct 23, 2024
@AllanZyne AllanZyne marked this pull request as draft October 24, 2024 07:06
@AllanZyne AllanZyne marked this pull request as ready for review November 20, 2024 08:29
@AllanZyne
Copy link
Contributor Author

Hi @oneapi-src/unified-runtime-maintain, could you please prioritize the review of this PR?
This PR has no functional change, and is essential for our further development!
Thank you very much!

Copy link
Contributor

@zhaomaosu zhaomaosu left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm

@pbalcer pbalcer self-requested a review November 20, 2024 11:36
@AllanZyne
Copy link
Contributor Author

AllanZyne commented Nov 21, 2024

I've pushed a commit to fix this in LLVM part.

ninja: error: '/home/test-user/actions-runners/opencl-1/_work/unified-runtime/unified-runtime/ur-repo/source/loader/layers/sanitizer/asan_libdevice.hpp', needed by 'lib/libsycl-asan-amdgcn-amd-amdhsa.bc', missing and no known rule to make it

@AllanZyne
Copy link
Contributor Author

Hi @pbalcer, could you please review and merge this PR before other sanitizer related PRs?
I've synced with other members.
Thank you very much!

@@ -93,10 +92,9 @@ void StackTrace::print() const {
BacktraceInfo BI = BacktraceSymbols[i];

// Skip runtime modules
if (!getContext()->interceptor->getOptions().Debug &&
Copy link
Contributor

@yingcong-wu yingcong-wu Nov 21, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we should keep verbosity printing for debug mode, maybe by creating a base class of option that have the common options available for all sanitizers, and in this case, the "debug" switch. But that can be addressed later.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I agree. Besides, I started to prefer to create a single option object for all sanitizers.
We can discuss this later.

@pbalcer
Copy link
Contributor

pbalcer commented Nov 21, 2024

Hi @pbalcer, could you please review and merge this PR before other sanitizer related PRs? I've synced with other members. Thank you very much!

Will do, is the PR final? I see that you are still making changes.

@AllanZyne
Copy link
Contributor Author

AllanZyne commented Nov 21, 2024

Hi @pbalcer, could you please review and merge this PR before other sanitizer related PRs? I've synced with other members. Thank you very much!

Will do, is the PR final? I see that you are still making changes.

Yes, it's final. I just pushed a commit to address a comment (copyright issue) by Yingcong.

Copy link
Contributor

@pbalcer pbalcer left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm, just a few nits.

Not insisting, but I think you should drop the prefixes on files if they are not necessary, so "common" instead of "sanitizer_common", "allocator.hpp" instead of "sanitizer_allocator.hpp" and so on.


using namespace asan;

static AsanInterceptor *interceptor;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Globals mess up constructor/destructor ordering, but I can see you tied its lifetime to the layer context, which is good. But can't we just leave the AsanInterceptor inside of the layer object?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

But can't we just leave the AsanInterceptor inside of the layer object?

Yes, I agree that using global variable is not a good idea.
We are going to develop each sanitizer as independent as possible at the beginning, and when these features are stable, we will try to extract their common characteristics, and create some base classes then.
Now I want the outside world (layer context) don't know how each sanitizer is implemented, and just give it some simple interfaces.

@pbalcer
Copy link
Contributor

pbalcer commented Nov 21, 2024

I'll merge this once you get an approval on your intel/llvm PR (you are missing llvm-reviewers-runtime, I'll approve on behalf of unified-runtime-reviewers).

@AllanZyne
Copy link
Contributor Author

lgtm, just a few nits.

Not insisting, but I think you should drop the prefixes on files if they are not necessary, so "common" instead of "sanitizer_common", "allocator.hpp" instead of "sanitizer_allocator.hpp" and so on.

For file naming style, I completely use the same way in compiler_rt (https://github.com/intel/llvm/tree/sycl/compiler-rt/lib/sanitizer_common) for convenience.

@pbalcer
Copy link
Contributor

pbalcer commented Nov 21, 2024

lgtm, just a few nits.
Not insisting, but I think you should drop the prefixes on files if they are not necessary, so "common" instead of "sanitizer_common", "allocator.hpp" instead of "sanitizer_allocator.hpp" and so on.

For file naming style, I completely use the same way in compiler_rt (https://github.com/intel/llvm/tree/sycl/compiler-rt/lib/sanitizer_common) for convenience.

Ok, makes sense, it's better to be consistent. Disregard that then.

@pbalcer pbalcer merged commit b5294ee into oneapi-src:main Nov 22, 2024
72 of 75 checks passed
steffenlarsen pushed a commit to intel/llvm that referenced this pull request Nov 22, 2024
UR: oneapi-src/unified-runtime#2232

Code refactoring for implementing MemorySanitizer

---------

Co-authored-by: Piotr Balcer <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

loader Loader related feature/bug sanitizer Sanitizer layer issues/changes/specification

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants