[sysprof] preload: add assertion for performance hack



commit 6d8841267a89714910832dff6e4f86ade86c33f1
Author: Christian Hergert <chergert redhat com>
Date:   Thu Mar 5 15:22:17 2020 -0800

    preload: add assertion for performance hack
    
    We steal two pointers temporarily, so ensure that we have the space to
    overwrite a couple of addresses.

 src/libsysprof/preload/sysprof-memory-collector.c | 4 ++++
 1 file changed, 4 insertions(+)
---
diff --git a/src/libsysprof/preload/sysprof-memory-collector.c 
b/src/libsysprof/preload/sysprof-memory-collector.c
index 6a13b64..002370f 100644
--- a/src/libsysprof/preload/sysprof-memory-collector.c
+++ b/src/libsysprof/preload/sysprof-memory-collector.c
@@ -77,6 +77,10 @@ backtrace_func (SysprofCaptureAddress *addrs,
                 guint                  n_addrs,
                 gpointer               user_data)
 {
+  /* Ensure we have at least two pointers to steal temporarily below */
+  G_STATIC_ASSERT (G_STRUCT_OFFSET (SysprofCaptureSample, addrs) >= 16);
+  G_STATIC_ASSERT (G_STRUCT_OFFSET (SysprofCaptureAllocation, addrs) >= 16);
+
 #if defined(ENABLE_LIBUNWIND)
 # if GLIB_SIZEOF_VOID_P == 8
   /* We know that collector will overwrite fields *AFTER* it


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]