I have #define MAX_CPU_ENGINES 4 lurking in my setup somewhere (I hardly ever use more than one CPU anyway).
In hconsts.h, MAX_CPU_ENGINES is defined to 64 or 128 but only if it is not already defined, so in my case, it remains defined as 4.
hconsts.h also defines DEFAULT_MAXCPU to be 8. It seems that DEFAULT_MAXCPU is used for just one purpose, to initialize sysblk.maxcpu in bldcfg.c. Also in bldcfg.c, sysblk.maxcpu is used to specify how many elements need to be initialized in some arrays, for example ptyp.
In hstructs.h, ptyp is declared to be an array of MAX_CPU_ENGINES elements.
In my case, when the code in bldcfg.c which initializes ptyp is executed, it runs off the end of the array and stomps onsysblk.todlock. This causes an access violation when hw_clock() is called a little later on.
Maybe when defining DEFAULT_MAXCPU, there should be a check that it is less than or equal to MAX_CPU_ENGINES or maybe sysblk.maxcpu should be initialized to the minimum of the two values?
On the other hand, maybe MAX_CPU_ENGINES should be used to specify how many elements to initialize in arrays declared to be of that size rather than sysblk.maxcpu or DEFAULT_MAXCPU?
I have
#define MAX_CPU_ENGINES 4
lurking in my setup somewhere (I hardly ever use more than one CPU anyway).In hconsts.h,
MAX_CPU_ENGINES
is defined to 64 or 128 but only if it is not already defined, so in my case, it remains defined as 4.hconsts.h also defines
DEFAULT_MAXCPU
to be 8. It seems thatDEFAULT_MAXCPU
is used for just one purpose, to initializesysblk.maxcpu
in bldcfg.c. Also in bldcfg.c,sysblk.maxcpu
is used to specify how many elements need to be initialized in some arrays, for exampleptyp
.In hstructs.h,
ptyp
is declared to be an array ofMAX_CPU_ENGINES
elements.In my case, when the code in bldcfg.c which initializes
ptyp
is executed, it runs off the end of the array and stomps onsysblk.todlock
. This causes an access violation whenhw_clock()
is called a little later on.Maybe when defining
DEFAULT_MAXCPU
, there should be a check that it is less than or equal toMAX_CPU_ENGINES
or maybesysblk.maxcpu
should be initialized to the minimum of the two values?On the other hand, maybe
MAX_CPU_ENGINES
should be used to specify how many elements to initialize in arrays declared to be of that size rather thansysblk.maxcpu
orDEFAULT_MAXCPU
?