Ishmael bugs

couple of places where PamDatablock.getLastUnit() was being used without
synchronization and the unit was being deleted between the line checking
there was a unit there and a line attempting to use the unit. Now
correctly synched so will get a unit you can use, or null.
This commit is contained in:
Douglas Gillespie 2022-11-18 09:55:17 +00:00
parent 35ee1e3dfc
commit 6f6f7407ca
2 changed files with 11 additions and 5 deletions

View File

@ -79,8 +79,9 @@ public class EnergySumProcess extends IshDetFnProcess {
EnergySumParams p = (EnergySumParams)ishDetControl.ishDetParams; EnergySumParams p = (EnergySumParams)ishDetControl.ishDetParams;
PamDataBlock inputDataBlock = getInputDataBlock(); //might be null PamDataBlock inputDataBlock = getInputDataBlock(); //might be null
if (inputDataBlock != null && inputDataBlock.getUnitsCount() > 0) { FFTDataUnit lastFFTUnit = ((FFTDataUnit)inputDataBlock.getLastUnit());
savedGramHeight = ((FFTDataUnit)inputDataBlock.getLastUnit()).getFftData().length(); if (lastFFTUnit != null) {
savedGramHeight = lastFFTUnit.getFftData().length();
int len = savedGramHeight; int len = savedGramHeight;
//Should be max(1,...) here, but FFT bin 0 has 0's in it. //Should be max(1,...) here, but FFT bin 0 has 0's in it.
loBin = Math.max(1, (int) Math.floor(len * p.f0 / (sampleRate/2))); loBin = Math.max(1, (int) Math.floor(len * p.f0 / (sampleRate/2)));

View File

@ -83,9 +83,14 @@ public class SgramCorrProcess extends IshDetFnProcess
protected void prepareMyParams() { protected void prepareMyParams() {
SgramCorrParams p = (SgramCorrParams)ishDetControl.ishDetParams; SgramCorrParams p = (SgramCorrParams)ishDetControl.ishDetParams;
PamDataBlock inputDataBlock = getInputDataBlock(); PamDataBlock inputDataBlock = getInputDataBlock();
/*
if (inputDataBlock != null && inputDataBlock.getUnitsCount() > 0) { * get the unit. first, then check it's null. Due to multithreading it's
savedGramHeight = ((FFTDataUnit)inputDataBlock.getLastUnit()).getFftData().length(); * possible that checking there are units and then asking for one,without
* synchronization will crash if the unit is deleted between those two calls.
*/
FFTDataUnit lastFFTUnit = ((FFTDataUnit)inputDataBlock.getLastUnit());
if (lastFFTUnit != null) {
savedGramHeight = lastFFTUnit.getFftData().length();
/* /*
* fft information is now stored in an FFTDataBLock, so no need to get * fft information is now stored in an FFTDataBLock, so no need to get
* back to the process above it. * back to the process above it.