hercules-390 / hyperion

Hercules 390
Other
252 stars 68 forks source link

Crash due to varying definitions of the maximum numbers of CPUs #153

Closed PeterCoghlan closed 8 years ago

PeterCoghlan commented 8 years ago

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?

Fish-Git commented 8 years ago

Thank you Peter!

PeterCoghlan commented 8 years ago

Many thanks Fish.

Hercules no longer crashes out when I set MAX_CPU_ENGINES to 4.