From 7cc64547b031fc273db779062c336a58e6741fc3 Mon Sep 17 00:00:00 2001 From: Joe Bryan Date: Wed, 13 Sep 2023 00:35:02 -0400 Subject: [PATCH] WIP debug broken migration (_cj_v1_free_hank()) --- pkg/noun/v1/jets.c | 70 +++++++++++++++++++++++++++++++++++++++++++- pkg/noun/v1/manage.c | 5 ++++ pkg/noun/v2/manage.c | 1 + 3 files changed, 75 insertions(+), 1 deletion(-) diff --git a/pkg/noun/v1/jets.c b/pkg/noun/v1/jets.c index 7e2f670f09..50aba7b7af 100644 --- a/pkg/noun/v1/jets.c +++ b/pkg/noun/v1/jets.c @@ -23,17 +23,81 @@ typedef struct { /** Functions. **/ +/* _cj_fink_free(): lose and free everything in a u3j_fink. +*/ +static void +_cj_v1_fink_free(u3p(u3j_fink) fin_p) +{ + fprintf(stderr, "_cj_v1_fink_free 1\r\n"); + c3_w i_w; + u3j_fink* fin_u = u3to(u3j_fink, fin_p); + fprintf(stderr, "_cj_v1_fink_free 2 %p %u %x\r\n", fin_u, fin_u->len_w, fin_p); + u3a_v1_lose(fin_u->sat); + fprintf(stderr, "_cj_v1_fink_free 3\r\n"); + for ( i_w = 0; i_w < fin_u->len_w; ++i_w ) { + u3j_fist* fis_u = &(fin_u->fis_u[i_w]); + fprintf(stderr, "_cj_v1_fink_free 4 %u\r\n", i_w); + u3a_v1_lose(fis_u->bat); + fprintf(stderr, "_cj_v1_fink_free 5 %u\r\n", i_w); + u3a_v1_lose(fis_u->pax); + fprintf(stderr, "_cj_v1_fink_free 6 %u\r\n", i_w); + } + + fprintf(stderr, "_cj_v1_fink_free 7\r\n"); + u3a_wfree(fin_u); + + fprintf(stderr, "_cj_v1_fink_free 8\r\n"); +} + +/* u3j_site_lose(): lose references of u3j_site (but do not free). + */ +void +u3j_v1_site_lose(u3j_site* sit_u) +{ + fprintf(stderr, "u3j_v1_site_lose 1\r\n"); + u3a_v1_lose(sit_u->axe); + fprintf(stderr, "u3j_v1_site_lose 2\r\n"); + if ( u3_none != sit_u->bat ) { + fprintf(stderr, "u3j_v1_site_lose 3\r\n"); + u3a_v1_lose(sit_u->bat); + } + if ( u3_none != sit_u->bas ) { + fprintf(stderr, "u3j_v1_site_lose 4\r\n"); + u3a_v1_lose(sit_u->bas); + } + fprintf(stderr, "u3j_v1_site_lose 5\r\n"); + if ( u3_none != sit_u->loc ) { + fprintf(stderr, "u3j_v1_site_lose 6\r\n"); + u3a_v1_lose(sit_u->loc); + fprintf(stderr, "u3j_v1_site_lose 7\r\n"); + u3a_v1_lose(sit_u->lab); + fprintf(stderr, "u3j_v1_site_lose 8\r\n"); + if ( c3y == sit_u->fon_o ) { + fprintf(stderr, "u3j_v1_site_lose 9\r\n"); + if ( sit_u->fin_p ) { + _cj_v1_fink_free(sit_u->fin_p); + } + } + } + fprintf(stderr, "u3j_v1_site_lose 10\r\n"); +} + /* _cj_v1_free_hank(): free an entry from the hank cache. ** NB: copy of _cj_v1_free_hank() from pkg/noun/jets.c */ static void _cj_v1_free_hank(u3_noun kev) { + fprintf(stderr, "_cj_v1_free_hank 1\r\n"); _cj_v1_hank* han_u = u3to(_cj_v1_hank, u3t(kev)); + fprintf(stderr, "_cj_v1_free_hank 2\r\n"); if ( u3_none != han_u->hax ) { + fprintf(stderr, "_cj_v1_free_hank 3\r\n"); u3a_v1_lose(han_u->hax); - u3j_site_lose(&(han_u->sit_u)); + fprintf(stderr, "_cj_v1_free_hank 4\r\n"); + u3j_v1_site_lose(&(han_u->sit_u)); } + fprintf(stderr, "_cj_v1_free_hank 5 %x %x\r\n", u3h(kev), u3t(kev)); u3a_wfree(han_u); } @@ -52,7 +116,11 @@ u3j_v1_reclaim(void) // clear the jet hank cache // + fprintf(stderr, "u3j_v1_reclaim 1 \r\n"); u3h_v1_walk(u3R->jed.han_p, _cj_v1_free_hank); + fprintf(stderr, "u3j_v1_reclaim 2 \r\n"); u3h_v1_free(u3R->jed.han_p); + fprintf(stderr, "u3j_v1_reclaim 3 \r\n"); u3R->jed.han_p = u3h_new(); // XX maybe initialize these at end of migration + fprintf(stderr, "u3j_v1_reclaim 4 \r\n"); } diff --git a/pkg/noun/v1/manage.c b/pkg/noun/v1/manage.c index 0eac6a8d7b..df0e3a0baf 100644 --- a/pkg/noun/v1/manage.c +++ b/pkg/noun/v1/manage.c @@ -13,8 +13,13 @@ void u3m_v1_reclaim(void) { + fprintf(stderr, "u3m_v1_reclaim 1\r\n"); u3v_v1_reclaim(); + fprintf(stderr, "u3m_v1_reclaim 2\r\n"); u3j_v1_reclaim(); + fprintf(stderr, "u3m_v1_reclaim 3\r\n"); u3n_v1_reclaim(); + fprintf(stderr, "u3m_v1_reclaim 4\r\n"); u3a_v1_reclaim(); + fprintf(stderr, "u3m_v1_reclaim 5\r\n"); } diff --git a/pkg/noun/v2/manage.c b/pkg/noun/v2/manage.c index a0509998ad..8b2dc2180f 100644 --- a/pkg/noun/v2/manage.c +++ b/pkg/noun/v2/manage.c @@ -34,6 +34,7 @@ _migrate_reclaim() // XX update this and similar printfs fprintf(stderr, "loom: migration reclaim\r\n"); u3m_v1_reclaim(); + fprintf(stderr, "loom: migration reclaim done\r\n"); } static void