public inbox for dtrace@lists.linux.dev
 help / color / mirror / Atom feed
* [PATCH 2/3] cg: validate tstring alloc/free
@ 2025-07-15 19:50 Kris Van Hees
  2025-07-16  4:45 ` Eugene Loh
  0 siblings, 1 reply; 7+ messages in thread
From: Kris Van Hees @ 2025-07-15 19:50 UTC (permalink / raw)
  To: dtrace, dtrace-devel

Rather than undiscriminantly resetting tstring allocations at the
beginning of a compilation, actually verify that alloc/free of
tstrings is done correctly, i.e. that none are left allocated after
compilation is done.

Signed-off-by: Kris Van Hees <kris.van.hees@oracle.com>
---
 libdtrace/dt_cg.c | 9 +++++----
 1 file changed, 5 insertions(+), 4 deletions(-)

diff --git a/libdtrace/dt_cg.c b/libdtrace/dt_cg.c
index bd0763d6..6c7ad076 100644
--- a/libdtrace/dt_cg.c
+++ b/libdtrace/dt_cg.c
@@ -1432,11 +1432,12 @@ dt_cg_tstring_reset(dtrace_hdl_t *dtp)
 		ts = dtp->dt_tstrings;
 		for (i = 0; i < DT_TSTRING_SLOTS; i++, ts++)
 			ts->offset = i * size;
+	} else {
+		/* Ensure that all allocated tstrings were freed correctly. */
+		ts = dtp->dt_tstrings;
+		for (i = 0; i < DT_TSTRING_SLOTS; i++, ts++)
+			assert(ts->in_use == 0);
 	}
-
-	ts = dtp->dt_tstrings;
-	for (i = 0; i < DT_TSTRING_SLOTS; i++, ts++)
-		ts->in_use = 0;
 }
 
 /*
-- 
2.45.2


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

end of thread, other threads:[~2025-07-17 18:21 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-07-15 19:50 [PATCH 2/3] cg: validate tstring alloc/free Kris Van Hees
2025-07-16  4:45 ` Eugene Loh
2025-07-16 23:07   ` Eugene Loh
2025-07-17  0:22     ` Kris Van Hees
2025-07-17  0:45       ` Eugene Loh
2025-07-17  4:59         ` Kris Van Hees
2025-07-17 18:20         ` Kris Van Hees

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