From 208e7f7706dca444cc97f0f1bc13d50dc377fff2 Mon Sep 17 00:00:00 2001 From: Josh Davies Date: Thu, 2 Jul 2026 16:41:52 +0100 Subject: [PATCH] fix: remove incorrect truncation of hide file when InParallel Setting POfull to POfill effectively truncates the hide file, and causes the next read from the HideFile to be taken from the "hole" at the start. Add more info to the HIDEDEBUG debug prints. --- check/fixes.frm | 117 ++++++++++++++++++++++++++++++++++++++++++++++ sources/proces.c | 6 +++ sources/store.c | 4 +- sources/threads.c | 1 - 4 files changed, 125 insertions(+), 3 deletions(-) diff --git a/check/fixes.frm b/check/fixes.frm index 48e5ec8d..8829ae83 100644 --- a/check/fixes.frm +++ b/check/fixes.frm @@ -4525,6 +4525,123 @@ assert stdout =~ exact_pattern(<<'EOF') sumpow: 129 EOF *--#] Issue796c : +*--#[ Issue856 : +#- +Off Statistics; +CFunction f,g,h; + +#define MODE "1" +#define MAX "4" + +* Each expression is a different size: +#do i = 1,`MAX' + Local test`i' = f(`i')^`i'; + Local htest`i' = g(`i')^{`i'+`MAX'}; + Local ihtest`i' = h(`i')^{`i'+2*`MAX'}; +#enddo +.sort + +* Start with "htest" expr hidden +Hide htest1,...,htest`MAX'; +.sort + +#do i = 1,`MAX' + UnHide htest`i'; + .sort + IntoHide ihtest`i'; + #if `MODE' == 1 + InParallel; + #endif + Multiply 2; + .sort + Hide htest`i'; +#enddo +.sort + +* UnHide all, mixture of InParallel and regular: +InParallel htest1,...,htest`MAX'; +UnHide; +.sort + + +* Reset +Hide htest1,...,htest`MAX'; +.sort + +* Same again, with UnHide in the inparallel module +#do i = 1,`MAX' + UnHide htest`i'; + IntoHide ihtest`i'; + #if `MODE' == 1 + InParallel; + #endif + Multiply 2; + .sort + Hide htest`i'; +#enddo +.sort + +UnHide; +.sort + + +* Reset +Hide htest1,...,htest`MAX'; +.sort + +* Same again, leave the first expression in the Hide file +#do i = 2,`MAX' + UnHide htest`i'; + .sort + IntoHide ihtest`i'; + #if `MODE' == 1 + InParallel; + #endif + Multiply 2; + .sort + Hide htest`i'; +#enddo +.sort + +UnHide; +.sort + + +* Reset +Hide htest1,...,htest`MAX'; +.sort + +* Same again, leave the first expression in the Hide file, but take from the end +#do i = `MAX',2,-1 + UnHide htest`i'; + .sort + IntoHide ihtest`i'; + #if `MODE' == 1 + InParallel; + #endif + Multiply 2; + .sort + Hide htest`i'; +#enddo +.sort + +UnHide; +Print; +.end +assert succeeded? +assert result("test1") =~ expr("16384*f(1)") +assert result("htest1") =~ expr("4*g(1)^5") +assert result("ihtest1") =~ expr("256*h(1)^9") +assert result("test2") =~ expr("16384*f(2)^2") +assert result("htest2") =~ expr("16*g(2)^6") +assert result("ihtest2") =~ expr("256*h(2)^10") +assert result("test3") =~ expr("16384*f(3)^3") +assert result("htest3") =~ expr("16*g(3)^7") +assert result("ihtest3") =~ expr("1024*h(3)^11") +assert result("test4") =~ expr("16384*f(4)^4") +assert result("htest4") =~ expr("16*g(4)^8") +assert result("ihtest4") =~ expr("4096*h(4)^12") +*--#] Issue856 : *--#[ PullReq535 : * This test requires more than the specified 50K workspace. #:maxtermsize 200 diff --git a/sources/proces.c b/sources/proces.c index 06df6280..7fe368f8 100644 --- a/sources/proces.c +++ b/sources/proces.c @@ -111,6 +111,9 @@ int Processor(void) AN.PolyFunTodo = 0; #ifdef HIDEDEBUG MesPrint("Status at the start of Processor (HideLevel = %d)",AC.HideLevel); + MesPrint("File %s POfill %l POfull %l POsize %l", AR.infile->name ,AR.infile->POfill -AR.infile->PObuffer ,AR.infile->POfull -AR.infile->PObuffer ,AR.infile->POsize/sizeof(WORD) ); + MesPrint("File %s POfill %l POfull %l POsize %l", AR.outfile->name ,AR.outfile->POfill -AR.outfile->PObuffer ,AR.outfile->POfull -AR.outfile->PObuffer ,AR.outfile->POsize/sizeof(WORD) ); + MesPrint("File %s POfill %l POfull %l POsize %l", AR.hidefile->name ,AR.hidefile->POfill-AR.hidefile->PObuffer,AR.hidefile->POfull-AR.hidefile->PObuffer,AR.hidefile->POsize/sizeof(WORD)); for ( i = 0; i < NumExpressions; i++ ) { e = Expressions+i; ExprStatus(e); @@ -644,6 +647,9 @@ commonread:; AT.WorkPointer = term; #ifdef HIDEDEBUG MesPrint("Status at the end of Processor (HideLevel = %d)",AC.HideLevel); + MesPrint("File %s POfill %l POfull %l POsize %l", AR.infile->name ,AR.infile->POfill -AR.infile->PObuffer ,AR.infile->POfull -AR.infile->PObuffer ,AR.infile->POsize/sizeof(WORD) ); + MesPrint("File %s POfill %l POfull %l POsize %l", AR.outfile->name ,AR.outfile->POfill -AR.outfile->PObuffer ,AR.outfile->POfull -AR.outfile->PObuffer ,AR.outfile->POsize/sizeof(WORD) ); + MesPrint("File %s POfill %l POfull %l POsize %l", AR.hidefile->name ,AR.hidefile->POfill-AR.hidefile->PObuffer,AR.hidefile->POfull-AR.hidefile->PObuffer,AR.hidefile->POsize/sizeof(WORD)); for ( i = 0; i < NumExpressions; i++ ) { e = Expressions+i; ExprStatus(e); diff --git a/sources/store.c b/sources/store.c index 22205611..b2b1db8c 100644 --- a/sources/store.c +++ b/sources/store.c @@ -119,8 +119,8 @@ void SetScratch(FILEHANDLE *f, POSITION *position) if ( f == AR.hidefile ) whichInInBuf = &(AR.InHiBuf); else whichInInBuf = &(AR.InInBuf); #ifdef HIDEDEBUG - if ( f == AR.hidefile ) MesPrint("In the hide file"); - else MesPrint("In the input file"); + if ( f == AR.hidefile ) MesPrint("In the hide file: %s", f->name); + else MesPrint("In the input file: %s", f->name); MesPrint("SetScratch to position %15p",position); MesPrint("POposition = %15p, full = %l, fill = %l" ,&(f->POposition),(f->POfull-f->PObuffer)*sizeof(WORD) diff --git a/sources/threads.c b/sources/threads.c index ebf7c8fd..13ebe463 100644 --- a/sources/threads.c +++ b/sources/threads.c @@ -1785,7 +1785,6 @@ bucketstolen:; goto ProcErr; } AB[0]->R.outfile = oldoutfile; - AB[0]->R.hidefile->POfull = AB[0]->R.hidefile->POfill; AB[0]->R.expflags = AR.expflags; UNLOCK(AS.outputslock);