Skip to content

Conversation

@GkvJwa
Copy link
Contributor

@GkvJwa GkvJwa commented Dec 14, 2025

Fix #134853

Since the Windows path separator is typically \\, replace it with /.

@llvmbot
Copy link
Member

llvmbot commented Dec 14, 2025

@llvm/pr-subscribers-compiler-rt-sanitizer

Author: None (GkvJwa)

Changes

Fix #134853

Since the Windows path separator is typically \\, replace it with /.


Full diff: https://github.com/llvm/llvm-project/pull/172194.diff

1 Files Affected:

  • (modified) compiler-rt/lib/hwasan/scripts/hwasan_symbolize (+1-1)
diff --git a/compiler-rt/lib/hwasan/scripts/hwasan_symbolize b/compiler-rt/lib/hwasan/scripts/hwasan_symbolize
index 19d948d1f0aaa..efc7c868696c3 100755
--- a/compiler-rt/lib/hwasan/scripts/hwasan_symbolize
+++ b/compiler-rt/lib/hwasan/scripts/hwasan_symbolize
@@ -476,7 +476,7 @@ def main():
   # Source location.
   paths_to_cut = args.source or []
   if not paths_to_cut:
-    paths_to_cut.append(os.getcwd() + '/')
+    paths_to_cut.append(os.getcwd().replace('\\', '/') + '/')
     if 'ANDROID_BUILD_TOP' in os.environ:
       paths_to_cut.append(os.environ['ANDROID_BUILD_TOP'] + '/')
 

@GkvJwa GkvJwa requested review from cjappl and fmayer December 14, 2025 04:07
@GkvJwa
Copy link
Contributor Author

GkvJwa commented Dec 14, 2025

Hello, @fmayer @cjappl If you have some free time, could you please review it

paths_to_cut = args.source or []
if not paths_to_cut:
paths_to_cut.append(os.getcwd() + '/')
paths_to_cut.append(os.getcwd().replace('\\', '/') + '/')
Copy link
Contributor

Choose a reason for hiding this comment

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

If this is python3, can we just use pathlib? I think they deal with the platform specific separators in a nice abstracted way

Copy link
Contributor Author

@GkvJwa GkvJwa Dec 15, 2025

Choose a reason for hiding this comment

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

from pathlib import Path
// On Windows, directly calling Path.cwd() also uses \\
path = Path.cwd()
>>> print(path)
C:\Users\a
// Calling as_posix can convert to /
path = Path.cwd().as_posix()
>>> print(path)
C:/Users/a

Requires explicit use of as_posix

The result is acceptable; it can be modified to cwd().as_posix().

Copy link
Contributor

Choose a reason for hiding this comment

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

yeah that is better. because your original code would theoretically replace a '' if it was part of cwd on unix, which is unlikely but still

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done, review again

The file header use

#!/usr/bin/env python3

I also removed the Python 2 compatibility logic.

@cjappl cjappl requested a review from eugenis December 14, 2025 19:51
@GkvJwa GkvJwa merged commit 818ac70 into llvm:main Dec 16, 2025
10 checks passed
@GkvJwa
Copy link
Contributor Author

GkvJwa commented Dec 16, 2025

Thanks

@GkvJwa GkvJwa deleted the main2 branch December 16, 2025 01:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[compiler-rt] hwasan_symbolize Windows bug

4 participants