From dfc57dda60762de3f3176147be655082036f56e8 Mon Sep 17 00:00:00 2001 From: Christopher Haster Date: Wed, 31 Dec 2025 12:25:49 -0600 Subject: [PATCH] Fixed uninitialized mtortoise blocks A simple but nasty typo! Quite confusing to figure out. Valgrind was quick to highlight that mtortoise was uninitialized, but without any sort of debugger support, it took many _many_ rereadings of the code to figure out what was actually going wrong. I even started to wonder if C's union aliasing rules were the culprit. To make matters worse, I only noticed Valgrind's warning because I was trying to find a heisenbug that turned out to be unrelated. Code changes minimal: code stack ctx before: 35144 2136 660 after: 35148 (+0.0%) 2136 (+0.0%) 660 (+0.0%) code stack ctx gbmap before: 38384 2144 776 gbmap after: 38388 (+0.0%) 2144 (+0.0%) 776 (+0.0%) code stack ctx preerase before: 38924 2168 796 preerase after: 38928 (+0.0%) 2168 (+0.0%) 796 (+0.0%) --- lfs3.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lfs3.c b/lfs3.c index c89e4419..ff6bf31e 100644 --- a/lfs3.c +++ b/lfs3.c @@ -9825,7 +9825,7 @@ again:; // setup mtortoise to detect cycles mtrv->u.mtortoise.blocks[0] = mtrv->h.mdir.r.blocks[0]; - mtrv->u.mtortoise.blocks[0] = mtrv->h.mdir.r.blocks[1]; + mtrv->u.mtortoise.blocks[1] = mtrv->h.mdir.r.blocks[1]; mtrv->u.mtortoise.dist = 0; mtrv->u.mtortoise.nlog2 = 0;