[llvm-branch-commits] [libcxx] release/21.x: [libc++][hardening] Add a greppable prefix to assertion messages. (#150560) (PR #151921)

2025-08-05 Thread via llvm-branch-commits

github-actions[bot] wrote:

@var-const (or anyone else). If you would like to add a note about this fix in 
the release notes (completely optional). Please reply to this comment with a 
one or two sentence description of the fix.  When you are done, please add the 
release:note label to this PR. 

https://github.com/llvm/llvm-project/pull/151921
___
llvm-branch-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits


[llvm-branch-commits] [libcxx] release/21.x: [libc++][hardening] Add a greppable prefix to assertion messages. (#150560) (PR #151921)

2025-08-05 Thread Tobias Hieta via llvm-branch-commits

https://github.com/tru closed https://github.com/llvm/llvm-project/pull/151921
___
llvm-branch-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits


[llvm-branch-commits] [libcxx] release/21.x: [libc++][hardening] Add a greppable prefix to assertion messages. (#150560) (PR #151921)

2025-08-05 Thread Tobias Hieta via llvm-branch-commits

https://github.com/tru updated https://github.com/llvm/llvm-project/pull/151921

>From 16bd92cdca5e0f29e109898e53bd71c31ce7593b Mon Sep 17 00:00:00 2001
From: Konstantin Varlamov 
Date: Thu, 31 Jul 2025 02:52:17 -0700
Subject: [PATCH] [libc++][hardening] Add a greppable prefix to assertion
 messages. (#150560)

The current assertion failure messages produced by Hardening are not
very grep-friendly (the common part is rarther generic and requires
wildcards to match). While it's possible to use `__FILE__` for grepping,
it's easier and more straighforward to simply add a libc++-specific
prefix; this is especially important for the planned `observe` mode that
might produce many assertion failure messages over the course of the
program's execution that later need to be filtered and examined.

(cherry picked from commit 4ef92469ab341ac1bee39a9413ffaa845e307414)
---
 libcxx/include/__assert   | 4 ++--
 libcxx/test/support/check_assertion.h | 4 ++--
 2 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/libcxx/include/__assert b/libcxx/include/__assert
index 90eaa6023587b..a9451daf47f2f 100644
--- a/libcxx/include/__assert
+++ b/libcxx/include/__assert
@@ -20,8 +20,8 @@
 #define _LIBCPP_ASSERT(expression, message)
\
   (__builtin_expect(static_cast(expression), 1)  
\
? (void)0   
\
-   : _LIBCPP_ASSERTION_HANDLER(__FILE__ ":" _LIBCPP_TOSTRING(__LINE__) ": 
assertion " _LIBCPP_TOSTRING(\
- expression) " failed: " message "\n"))
+   : _LIBCPP_ASSERTION_HANDLER(__FILE__ ":" _LIBCPP_TOSTRING(  
\
+ __LINE__) ": libc++ Hardening assertion " 
_LIBCPP_TOSTRING(expression) " failed: " message "\n"))
 
 // WARNING: __builtin_assume can currently inhibit optimizations. Only add 
assumptions with a clear
 // optimization intent. See 
https://discourse.llvm.org/t/llvm-assume-blocks-optimization/71609 for a
diff --git a/libcxx/test/support/check_assertion.h 
b/libcxx/test/support/check_assertion.h
index a091043195345..8416de76cfd61 100644
--- a/libcxx/test/support/check_assertion.h
+++ b/libcxx/test/support/check_assertion.h
@@ -52,8 +52,8 @@ MatchResult MatchAssertionMessage(const std::string& text, 
std::string_view expe
   // library.
   std::string assertion_format_string = [&] {
 if (use_marker)
-  return (".*###\\n(.*):(\\d+): assertion (.*) failed: (.*)\\n###");
-return ("(.*):(\\d+): assertion (.*) failed: (.*)\\n");
+  return (".*###\\n(.*):(\\d+): libc\\+\\+ Hardening assertion (.*) 
failed: (.*)\\n###");
+return ("(.*):(\\d+): libc\\+\\+ Hardening assertion (.*) failed: 
(.*)\\n");
   }();
   std::regex assertion_format(assertion_format_string);
 

___
llvm-branch-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits


[llvm-branch-commits] [libcxx] release/21.x: [libc++][hardening] Add a greppable prefix to assertion messages. (#150560) (PR #151921)

2025-08-04 Thread Konstantin Varlamov via llvm-branch-commits

https://github.com/var-const approved this pull request.


https://github.com/llvm/llvm-project/pull/151921
___
llvm-branch-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits


[llvm-branch-commits] [libcxx] release/21.x: [libc++][hardening] Add a greppable prefix to assertion messages. (#150560) (PR #151921)

2025-08-04 Thread via llvm-branch-commits

llvmbot wrote:




@llvm/pr-subscribers-libcxx

Author: None (llvmbot)


Changes

Backport 4ef92469ab341ac1bee39a9413ffaa845e307414

Requested by: @var-const

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


2 Files Affected:

- (modified) libcxx/include/__assert (+2-2) 
- (modified) libcxx/test/support/check_assertion.h (+2-2) 


``diff
diff --git a/libcxx/include/__assert b/libcxx/include/__assert
index 90eaa6023587b..a9451daf47f2f 100644
--- a/libcxx/include/__assert
+++ b/libcxx/include/__assert
@@ -20,8 +20,8 @@
 #define _LIBCPP_ASSERT(expression, message)
\
   (__builtin_expect(static_cast(expression), 1)  
\
? (void)0   
\
-   : _LIBCPP_ASSERTION_HANDLER(__FILE__ ":" _LIBCPP_TOSTRING(__LINE__) ": 
assertion " _LIBCPP_TOSTRING(\
- expression) " failed: " message "\n"))
+   : _LIBCPP_ASSERTION_HANDLER(__FILE__ ":" _LIBCPP_TOSTRING(  
\
+ __LINE__) ": libc++ Hardening assertion " 
_LIBCPP_TOSTRING(expression) " failed: " message "\n"))
 
 // WARNING: __builtin_assume can currently inhibit optimizations. Only add 
assumptions with a clear
 // optimization intent. See 
https://discourse.llvm.org/t/llvm-assume-blocks-optimization/71609 for a
diff --git a/libcxx/test/support/check_assertion.h 
b/libcxx/test/support/check_assertion.h
index a091043195345..8416de76cfd61 100644
--- a/libcxx/test/support/check_assertion.h
+++ b/libcxx/test/support/check_assertion.h
@@ -52,8 +52,8 @@ MatchResult MatchAssertionMessage(const std::string& text, 
std::string_view expe
   // library.
   std::string assertion_format_string = [&] {
 if (use_marker)
-  return (".*###\\n(.*):(\\d+): assertion (.*) failed: (.*)\\n###");
-return ("(.*):(\\d+): assertion (.*) failed: (.*)\\n");
+  return (".*###\\n(.*):(\\d+): libc\\+\\+ Hardening assertion (.*) 
failed: (.*)\\n###");
+return ("(.*):(\\d+): libc\\+\\+ Hardening assertion (.*) failed: 
(.*)\\n");
   }();
   std::regex assertion_format(assertion_format_string);
 

``




https://github.com/llvm/llvm-project/pull/151921
___
llvm-branch-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits


[llvm-branch-commits] [libcxx] release/21.x: [libc++][hardening] Add a greppable prefix to assertion messages. (#150560) (PR #151921)

2025-08-04 Thread via llvm-branch-commits

https://github.com/llvmbot milestoned 
https://github.com/llvm/llvm-project/pull/151921
___
llvm-branch-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits


[llvm-branch-commits] [libcxx] release/21.x: [libc++][hardening] Add a greppable prefix to assertion messages. (#150560) (PR #151921)

2025-08-04 Thread via llvm-branch-commits

https://github.com/llvmbot created 
https://github.com/llvm/llvm-project/pull/151921

Backport 4ef92469ab341ac1bee39a9413ffaa845e307414

Requested by: @var-const

>From 908b0e5893ce79231cb4e613da9c80f76a6ae1ed Mon Sep 17 00:00:00 2001
From: Konstantin Varlamov 
Date: Thu, 31 Jul 2025 02:52:17 -0700
Subject: [PATCH] [libc++][hardening] Add a greppable prefix to assertion
 messages. (#150560)

The current assertion failure messages produced by Hardening are not
very grep-friendly (the common part is rarther generic and requires
wildcards to match). While it's possible to use `__FILE__` for grepping,
it's easier and more straighforward to simply add a libc++-specific
prefix; this is especially important for the planned `observe` mode that
might produce many assertion failure messages over the course of the
program's execution that later need to be filtered and examined.

(cherry picked from commit 4ef92469ab341ac1bee39a9413ffaa845e307414)
---
 libcxx/include/__assert   | 4 ++--
 libcxx/test/support/check_assertion.h | 4 ++--
 2 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/libcxx/include/__assert b/libcxx/include/__assert
index 90eaa6023587b..a9451daf47f2f 100644
--- a/libcxx/include/__assert
+++ b/libcxx/include/__assert
@@ -20,8 +20,8 @@
 #define _LIBCPP_ASSERT(expression, message)
\
   (__builtin_expect(static_cast(expression), 1)  
\
? (void)0   
\
-   : _LIBCPP_ASSERTION_HANDLER(__FILE__ ":" _LIBCPP_TOSTRING(__LINE__) ": 
assertion " _LIBCPP_TOSTRING(\
- expression) " failed: " message "\n"))
+   : _LIBCPP_ASSERTION_HANDLER(__FILE__ ":" _LIBCPP_TOSTRING(  
\
+ __LINE__) ": libc++ Hardening assertion " 
_LIBCPP_TOSTRING(expression) " failed: " message "\n"))
 
 // WARNING: __builtin_assume can currently inhibit optimizations. Only add 
assumptions with a clear
 // optimization intent. See 
https://discourse.llvm.org/t/llvm-assume-blocks-optimization/71609 for a
diff --git a/libcxx/test/support/check_assertion.h 
b/libcxx/test/support/check_assertion.h
index a091043195345..8416de76cfd61 100644
--- a/libcxx/test/support/check_assertion.h
+++ b/libcxx/test/support/check_assertion.h
@@ -52,8 +52,8 @@ MatchResult MatchAssertionMessage(const std::string& text, 
std::string_view expe
   // library.
   std::string assertion_format_string = [&] {
 if (use_marker)
-  return (".*###\\n(.*):(\\d+): assertion (.*) failed: (.*)\\n###");
-return ("(.*):(\\d+): assertion (.*) failed: (.*)\\n");
+  return (".*###\\n(.*):(\\d+): libc\\+\\+ Hardening assertion (.*) 
failed: (.*)\\n###");
+return ("(.*):(\\d+): libc\\+\\+ Hardening assertion (.*) failed: 
(.*)\\n");
   }();
   std::regex assertion_format(assertion_format_string);
 

___
llvm-branch-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits


[llvm-branch-commits] [libcxx] release/21.x: [libc++][hardening] Add a greppable prefix to assertion messages. (#150560) (PR #151921)

2025-08-04 Thread via llvm-branch-commits

llvmbot wrote:

@var-const What do you think about merging this PR to the release branch?

https://github.com/llvm/llvm-project/pull/151921
___
llvm-branch-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits