Opened 13 years ago
Closed 13 years ago
#1515 closed defect (fixed)
ppStack segv when using recipe STACK_1DG
| Reported by: | bills | Owned by: | |
|---|---|---|---|
| Priority: | high | Milestone: | |
| Component: | ppStack | Version: | |
| Severity: | normal | Keywords: | |
| Cc: |
Description
stack 2641329 and others die with fault 4
The error is in the function psMMGMM
i - offsets->data.S32[i] < 0 which leads to access outside the bounds of an array
for (int i = 0; i < N - Ncensored; i++) {
modes->data.F32[i - offsets->data.S32[i]] = tempModes->data.F32[i];
for (int j = 0; j < dim; j++) {
P->data.F32[i - offsets->data.S32[i]][j] = tempP->data.F32[i][j];
}
}
If the block of code is skipped when the invalid offset is detected
a memory corruption is detected later indicating that other
bad things may be going on.
Note:
See TracTickets
for help on using tickets.

v36180 of psMixtureModels.c contains the fix for this.
I had the direction of the offsets reversed: "i - offsets[i]" will go negative, whereas "i + offsets[i]" properly places values where they belong.
This revision also contains a calculation fix for the initial population fractions. It was coming up with [1.0 0.0] for the initial fractions, and then failing to fit the second mode. I've reset this to be [0.5 0.5], which may be slightly slower (the first EM iteration will generate a better fraction, which the previous calculation was supposed to do automatically), but converges to the correct values.