Closed f4exb closed 7 months ago
I noticed there are some test programs in the testfec sub directory. It seems golay20 also accesses indexes that are out of range, so should be an easier test case to debug:
For the last two test cases:
Flip three bits (1,15,21) - 2 in parity
1 1 0 1 0 1 0 0 1 0 1 0 0 0 1 1 1 0 1 1
Golay_20_8: idx out of range 23
1 0 0 1 0 1 0 0
Decoding OK
Flip three bits (15,18,21) - all parity
1 0 0 1 0 1 0 0 1 0 1 0 0 0 1 1 1 0 0 1
Golay_20_8: idx out of range 22
Golay_20_8: idx out of range 23
1 0 0 1 0 1 0 0
Decoding OK
Added some checks on indexes for the other code in fec.c, and the other tests appear to run without a problem.
I suspect the problem is in Golay_20_8::init()
In this loop, which appears to iterate over the 12 parity bits, the last line generates a index > 20
// 1 possible bit flip left in the parity part
for (int ip = 0; ip < 12; ip++)
{
int syndromeIP = syndromeI ^ (1 << (11-ip));
m_corr[syndromeIP][0] = i1;
m_corr[syndromeIP][1] = i2;
m_corr[syndromeIP][2] = 12 + ip; // Illegal index generated here
I'm guessing this may be a cut an paste error from Golay_23_12, which has the same code, but a different number of data and parity bits.
As far as I can see Golay_20_8 has just 8 data bits, and 12 parity bits, and this table seems to be the index of a bit to correct, so I guess this code should be:
m_corr[syndromeIP][2] = 8 + ip;
There are a few other uses of 12 + ... in that function that I guess need to change too.
This issue is going to be closed due to inactivity
The issues are actually described here: https://github.com/f4exb/sdrangel/issues/1878