Bulletin number: 374 Products affected: D4214B D5214B D7214C Description: T2 version of ProcPriPar in C maintenance release Component: icc Date: Fri Nov 8 10:43:33 GMT 1991 ----- Ref: TS/1281 A bug exists in the T2 version of the ProcPriPar function in the C maintenance release. If the workspace pointer of the high priority process to be started is not aligned on a 4 byte boundary then a "rogue" process will be started which will completely corrupt the program. A source workaround is to ensure that the workspace pointer is aligned correctly. Usually the user would issue the following command to set up the high priority process: Process *p; p = ProcAlloc(hifunc, 1024, 1, param1); if (p == NULL) { printf ("unable to allocate high process\n"); exit (EXIT_FAILURE); } Similar results can be achieved by using ProcInit and checking that the workspace pointer is aligned correctly. Replace the above code with something like the following: Process *p; int psize = 1; /* size of parameter list in words */ int wsize = 1024; /* required workspace size in bytes */ int *highstackspace, *highstack, *wpaddr; /* allocate the workspace + 1 word leeway */ highstackspace = (int *) malloc (wsize + sizeof (int)); /* allocate space for process structure */ p = (Process *) malloc (sizeof (Process)); if ((highstackspace == NULL) || (p == NULL)) { printf ("malloc failed for high process creation\n"); exit (EXIT_FAILURE); } /* save the workspace pointer so we can free it later if required */ highstack = highstackspace; /* This calculates the workspace pointer for the high priority process */ wpaddr = (int *)((int) highstack + wsize - (sizeof (int) * 3) - (sizeof (int) * (psize + 1))); /* check its alignment and adjust if necessary */ if (((int) wpaddr % 4) != 0) ++highstack; /* one word on a T2 == 2 bytes */ /* set up the process */ if (ProcInit (p, highfunc, highstack, wsize, psize, param1)) { printf ("unable to set up high process\n"); exit (EXIT_FAILURE); } The above works by calculating the address of the workspace pointer used when the high priority process is first started. If this is not aligned on a four byte boundary then the entire workspace is shifted up by 1 word which ensures that the workspace pointer will be aligned correctly. This extra word is accommodated by the leeway allowed in the call to malloc. The process is then set up using ProcInit. Note that just checking that the memory returned by malloc is aligned on a 4 byte boundary is not sufficient. highstackspace can be used if the workspace is ever required to be freed. Note that highstack cannot be used in a call to free as it may have been modified.