From 0aca19356cceb804c0a70fd41a9f35e6ad840771 Mon Sep 17 00:00:00 2001 From: Martin Whitaker Date: Sat, 18 May 2013 19:02:36 +0100 Subject: [PATCH] Added thread stack memory leak check to vvp. When a vvp thread terminates, its real and string stacks should be empty. Adding assertions to this effect catches some code generator bugs. --- vvp/vthread.cc | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/vvp/vthread.cc b/vvp/vthread.cc index bd294ab48..bc097757d 100644 --- a/vvp/vthread.cc +++ b/vvp/vthread.cc @@ -217,6 +217,13 @@ struct vthread_s { /* These are used to pass non-blocking event control information. */ vvp_net_t*event; uint64_t ecount; + + inline void cleanup() + { + bits4 = vvp_vector4_t(); + assert(stack_real_.empty()); + assert(stack_str_.empty()); + } }; inline vthread_s::vthread_s() @@ -618,7 +625,7 @@ static void vthread_reap(vthread_t thr) void vthread_delete(vthread_t thr) { - thr->bits4 = vvp_vector4_t(); + thr->cleanup(); delete thr; }