From 4a5b56eff5a5122195e1976da00a586c724216f4 Mon Sep 17 00:00:00 2001 From: Joe Bryan Date: Thu, 10 Nov 2022 12:33:21 -0500 Subject: [PATCH 1/2] u3: reposition guard page if needed for new roads this works around a bug wherein the guard page could become nonoperable if it happened to coincide with the padding between inner roads --- pkg/urbit/include/noun/events.h | 7 ++++++- pkg/urbit/noun/events.c | 14 ++++++++++++++ pkg/urbit/noun/manage.c | 2 ++ 3 files changed, 22 insertions(+), 1 deletion(-) diff --git a/pkg/urbit/include/noun/events.h b/pkg/urbit/include/noun/events.h index 92d5c2a75e..7edf44a2f9 100644 --- a/pkg/urbit/include/noun/events.h +++ b/pkg/urbit/include/noun/events.h @@ -84,9 +84,14 @@ void u3e_foul(void); - /* u3e_init(): initialize page tracking. + /* u3e_init(): initialize guard page tracking. */ void u3e_init(void); + /* u3e_ward(): reposition guard page if needed. + */ + void + u3e_ward(u3_post low_p, u3_post hig_p); + #endif /* ifndef U3_EVENTS_H */ diff --git a/pkg/urbit/noun/events.c b/pkg/urbit/noun/events.c index 6986e91a22..ec2a995d1c 100644 --- a/pkg/urbit/noun/events.c +++ b/pkg/urbit/noun/events.c @@ -1097,6 +1097,8 @@ u3e_foul(void) memset((void*)u3P.dit_w, 0xff, sizeof(u3P.dit_w)); } +/* u3e_init(): initialize guard page tracking. +*/ void u3e_init(void) { @@ -1104,3 +1106,15 @@ u3e_init(void) _ce_center_guard_page(); #endif } + +/* u3e_ward(): reposition guard page if needed. +*/ +void +u3e_ward(u3_post low_p, u3_post hig_p) +{ +#ifdef U3_GUARD_PAGE + if ( (low_p > gar_pag_p) || (hig_p < gar_pag_p) ) { + _ce_center_guard_page(); + } +#endif +} diff --git a/pkg/urbit/noun/manage.c b/pkg/urbit/noun/manage.c index c0659f42b9..69e5f4b651 100644 --- a/pkg/urbit/noun/manage.c +++ b/pkg/urbit/noun/manage.c @@ -803,6 +803,7 @@ u3m_leap(c3_w pad_w) u3R->cap_p -= len_w; rod_u = _pave_south(u3a_into(bot_p), c3_wiseof(u3a_road), len_w); + u3e_ward(rod_u->cap_p, rod_u->hat_p); #if 0 fprintf(stderr, "leap: from north %p (cap 0x%x), to south %p\r\n", u3R, @@ -815,6 +816,7 @@ u3m_leap(c3_w pad_w) u3R->cap_p += len_w; rod_u = _pave_north(u3a_into(bot_p), c3_wiseof(u3a_road), len_w); + u3e_ward(rod_u->hat_p, rod_u->cap_p); #if 0 fprintf(stderr, "leap: from south %p (cap 0x%x), to north %p\r\n", u3R, From eb7c289ded8f2dc0e9916ce5f2a15aefb677ac34 Mon Sep 17 00:00:00 2001 From: Joe Bryan Date: Thu, 10 Nov 2022 12:35:00 -0500 Subject: [PATCH 2/2] test: initialize guard page in jam-tests --- pkg/urbit/tests/jam_tests.c | 1 + 1 file changed, 1 insertion(+) diff --git a/pkg/urbit/tests/jam_tests.c b/pkg/urbit/tests/jam_tests.c index eebc27fc1f..55a83009b1 100644 --- a/pkg/urbit/tests/jam_tests.c +++ b/pkg/urbit/tests/jam_tests.c @@ -8,6 +8,7 @@ _setup(void) { u3m_init(); u3m_pave(c3y); + u3e_init(); } static void