]> git.ipfire.org Git - thirdparty/valgrind.git/commitdiff
Make memcheck tests demangle and demangle-rust clang-friendly.
authorPaul Floyd <pjfloyd@wanadoo.fr>
Fri, 12 Nov 2021 22:44:54 +0000 (23:44 +0100)
committerPaul Floyd <pjfloyd@wanadoo.fr>
Fri, 12 Nov 2021 22:44:54 +0000 (23:44 +0100)
Clang uses CMOV for ternary operators which does not immediately
trigger an error. Using double free and new/free mismatch still
poses no problem with clang but still uses the demangling.

Also update .gitignore

.gitignore
memcheck/tests/demangle-rust.c
memcheck/tests/demangle-rust.stderr.exp
memcheck/tests/demangle.cpp
memcheck/tests/demangle.stderr.exp

index 6a94e6c82d20c699139bd3a654dd7c0c42c2c47f..770d08c2784206da5ce720946efbf42c07441a3a 100644 (file)
 /memcheck/tests/deep-backtrace
 /memcheck/tests/deep_templates
 /memcheck/tests/demangle
+/memcheck/tests/demangle-rust
 /memcheck/tests/describe-block
 /memcheck/tests/descr_belowsp
 /memcheck/tests/dir
index f2a458b2acfba55bce6a3b805ec07df906ecb1ae..f5805ff42bbc4a3547bb6d999ab51b61af51e00a 100644 (file)
@@ -9,7 +9,9 @@
 // A v0 symbol that demangles to: <rustc_middle::ty::PredicateKind as rustc_middle::ty::fold::TypeFoldable>::fold_with::<rustc_infer::infer::resolve::OpportunisticVarResolver>
 int _RINvYNtNtCs4uGc65yWeeX_12rustc_middle2ty13PredicateKindNtNtB5_4fold12TypeFoldable9fold_withNtNtNtCsgI90OQiJWEs_11rustc_infer5infer7resolve24OpportunisticVarResolverECsdozMG8X9FIu_21rustc_trait_selection(int *p)
 {
-   return *p ? 1 : 2;
+   free(p);
+   free(p);
+   return 1;
 }
 
 // A v0 symbol that demangles to: rustc_expand::mbe::macro_parser::parse_tt
index f04bb625b14852f3e263ca95a77c738872f1ad11..6579f0842686e033f27a6747dec5cc6469eec3d3 100644 (file)
@@ -1,6 +1,16 @@
-Conditional jump or move depends on uninitialised value(s)
-   at 0x........: <rustc_middle::ty::PredicateKind as rustc_middle::ty::fold::TypeFoldable>::fold_with::<rustc_infer::infer::resolve::OpportunisticVarResolver> (demangle-rust.c:12)
-   by 0x........: rustc_expand::mbe::macro_parser::parse_tt (demangle-rust.c:18)
-   by 0x........: core::str::lossy::Utf8Lossy::from_bytes (demangle-rust.c:24)
-   by 0x........: main (demangle-rust.c:29)
+Invalid free() / delete / delete[] / realloc()
+   at 0x........: free (vg_replace_malloc.c:...)
+   by 0x........: <rustc_middle::ty::PredicateKind as rustc_middle::ty::fold::TypeFoldable>::fold_with::<rustc_infer::infer::resolve::OpportunisticVarResolver> (demangle-rust.c:13)
+   by 0x........: rustc_expand::mbe::macro_parser::parse_tt (demangle-rust.c:20)
+   by 0x........: core::str::lossy::Utf8Lossy::from_bytes (demangle-rust.c:26)
+   by 0x........: main (demangle-rust.c:31)
+ Address 0x........ is 0 bytes inside a block of size 4 free'd
+   at 0x........: free (vg_replace_malloc.c:...)
+   by 0x........: <rustc_middle::ty::PredicateKind as rustc_middle::ty::fold::TypeFoldable>::fold_with::<rustc_infer::infer::resolve::OpportunisticVarResolver> (demangle-rust.c:12)
+   by 0x........: rustc_expand::mbe::macro_parser::parse_tt (demangle-rust.c:20)
+   by 0x........: core::str::lossy::Utf8Lossy::from_bytes (demangle-rust.c:26)
+   by 0x........: main (demangle-rust.c:31)
+ Block was alloc'd at
+   at 0x........: malloc (vg_replace_malloc.c:...)
+   by 0x........: main (demangle-rust.c:31)
 
index ff15fe12c364e6d6f6e8318c79e6cef2ee5f4771..9922bf405f2b39c4b121490e76bcb68618492f14 100644 (file)
@@ -1,4 +1,5 @@
 // Simple smoke test to see that the demangler is actually working
+#include <cstdlib>
 
 namespace abc {
 template <typename T1, typename T2> 
@@ -6,7 +7,8 @@ class def {
   public:
     T1 xyzzy(T1 *p, T2 *)
     {
-      return *p ? 10 : 20;
+      free(p);
+      return 10;
     }
   };
 };
index 6e7467d7cf9296c3ee52956d0f13711af1182650..4a4dc87d7f299e360111ca45ddaa6125ab73a926 100644 (file)
@@ -1,5 +1,9 @@
-Conditional jump or move depends on uninitialised value(s)
-   at 0x........: abc::def<int, magic<int> >::xyzzy(int*, magic<int>*) (demangle.cpp:9)
-   by 0x........: magic<int>::xyzzy(int*) (demangle.cpp:19)
-   by 0x........: main (demangle.cpp:27)
+Mismatched free() / delete / delete []
+   at 0x........: free (vg_replace_malloc.c:...)
+   by 0x........: abc::def<int, magic<int> >::xyzzy(int*, magic<int>*) (demangle.cpp:10)
+   by 0x........: magic<int>::xyzzy(int*) (demangle.cpp:21)
+   by 0x........: main (demangle.cpp:29)
+ Address 0x........ is 0 bytes inside a block of size 4 alloc'd
+   at 0x........: ...operator new... (vg_replace_malloc.c:...)
+   by 0x........: main (demangle.cpp:29)