Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
* [patch] Fix LD_PRELOAD=/usr/lib64/libasan.so.6 gdb
@ 2021-05-02 13:34 Jan Kratochvil via Gdb-patches
  2021-05-02 13:39 ` Simon Marchi via Gdb-patches
  0 siblings, 1 reply; 5+ messages in thread
From: Jan Kratochvil via Gdb-patches @ 2021-05-02 13:34 UTC (permalink / raw)
  To: gdb-patches

[-- Attachment #1: Type: text/plain, Size: 803 bytes --]

Hi,

AddressSanitizer: alloc-dealloc-mismatch (malloc vs operator delete) on 0x613000000040
https://bugzilla.redhat.com/show_bug.cgi?id=1510413

The gdb binary had so far on Fedora 34 x86_64:

                 U operator delete[](void*)
                 U operator delete[](void*, unsigned long)
                 U operator delete(void*, unsigned long)

While now there are defined all these - but IMO it is a bit unpredictable
which will be used in the future:

00000000000000c0 T operator delete[](void*)
00000000000000d0 T operator delete[](void*, std::nothrow_t const&)
00000000000000e0 T operator delete[](void*, unsigned long)
0000000000000090 T operator delete(void*)
00000000000000a0 T operator delete(void*, std::nothrow_t const&)
00000000000000b0 T operator delete(void*, unsigned long)


Jan

[-- Attachment #2: 1 --]
[-- Type: text/plain, Size: 1119 bytes --]

gdbsupport/
2021-05-02  Jan Kratochvil  <jan.kratochvil@redhat.com>

	* new-op.cc (opertor delete 6x): New.

diff --git a/gdbsupport/new-op.cc b/gdbsupport/new-op.cc
index 5ab19621a43..f70d3ef191d 100644
--- a/gdbsupport/new-op.cc
+++ b/gdbsupport/new-op.cc
@@ -92,4 +92,44 @@ operator new[] (std::size_t sz, const std::nothrow_t&) noexcept
 {
   return ::operator new (sz, std::nothrow);
 }
+
+/* Define also operators delete as one can LD_PRELOAD=libasan.so.*
+   without recompiling the program with -fsanitize=address . */
+
+void
+operator delete (void *p)
+{
+  free (p);
+}
+
+void
+operator delete (void *p, const std::nothrow_t&) noexcept
+{
+  return ::operator delete (p);
+}
+
+void
+operator delete (void *p, std::size_t) noexcept
+{
+  return ::operator delete (p, std::nothrow);
+}
+
+void
+operator delete[] (void *p)
+{
+  return ::operator delete (p);
+}
+
+void
+operator delete[] (void *p, const std::nothrow_t&) noexcept
+{
+  return ::operator delete (p, std::nothrow);
+}
+
+void
+operator delete[] (void *p, std::size_t) noexcept
+{
+  return ::operator delete[] (p, std::nothrow);
+}
+
 #endif

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2021-05-02 14:42 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-05-02 13:34 [patch] Fix LD_PRELOAD=/usr/lib64/libasan.so.6 gdb Jan Kratochvil via Gdb-patches
2021-05-02 13:39 ` Simon Marchi via Gdb-patches
2021-05-02 13:56   ` Jan Kratochvil via Gdb-patches
2021-05-02 14:30     ` Simon Marchi via Gdb-patches
2021-05-02 14:41       ` Jan Kratochvil via Gdb-patches

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox