nasa / CF

The Core Flight System (cFS) CFDP application.
Apache License 2.0
78 stars 45 forks source link

`Test_CF_Chunks_InsertChunk_PutGiven_chunk_IntoSome_chunks` occasionally fails on 32 bit system #214

Closed skliper closed 2 years ago

skliper commented 2 years ago

Checklist (Please check before submitting)

Describe the bug Not clear what the issue is, but random values being used in test. Output observed:

[BEGIN] 16 Test_CF_Chunks_InsertChunk_PutGiven_chu
[ PASS] 16.001 cf_chunk_tests.c:581 - arg_chunks->count (11) == initial_count + 1 (11)
[ PASS] 16.002 cf_chunk_tests.c:586 - arg_chunks->chunks[i].offset (1762369143) == updated_offsets[i] (1762369143)
[ PASS] 16.003 cf_chunk_tests.c:588 - arg_chunks->chunks[i].size (847905902) == updated_sizes[i] (847905902)
[ FAIL] 16.004 cf_chunk_tests.c:586 - arg_chunks->chunks[i].offset (628830104) == updated_offsets[i] (1341639884)
[ PASS] 16.005 cf_chunk_tests.c:588 - arg_chunks->chunks[i].size (547308955) == updated_sizes[i] (547308955)
[ PASS] 16.006 cf_chunk_tests.c:586 - arg_chunks->chunks[i].offset (1708400675) == updated_offsets[i] (1708400675)
[ PASS] 16.007 cf_chunk_tests.c:588 - arg_chunks->chunks[i].size (1747104817) == updated_sizes[i] (1747104817)
[ PASS] 16.008 cf_chunk_tests.c:586 - arg_chunks->chunks[i].offset (1839674080) == updated_offsets[i] (1839674080)
[ PASS] 16.009 cf_chunk_tests.c:588 - arg_chunks->chunks[i].size (19865785) == updated_sizes[i] (19865785)
[ PASS] 16.010 cf_chunk_tests.c:586 - arg_chunks->chunks[i].offset (635068937) == updated_offsets[i] (635068937)
[ PASS] 16.011 cf_chunk_tests.c:588 - arg_chunks->chunks[i].size (262748747) == updated_sizes[i] (262748747)
[ PASS] 16.012 cf_chunk_tests.c:586 - arg_chunks->chunks[i].offset (1807586308) == updated_offsets[i] (1807586308)
[ PASS] 16.013 cf_chunk_tests.c:588 - arg_chunks->chunks[i].size (638705114) == updated_sizes[i] (638705114)
[ PASS] 16.014 cf_chunk_tests.c:586 - arg_chunks->chunks[i].offset (1600046893) == updated_offsets[i] (1600046893)
[ PASS] 16.015 cf_chunk_tests.c:588 - arg_chunks->chunks[i].size (376990135) == updated_sizes[i] (376990135)
[ PASS] 16.016 cf_chunk_tests.c:586 - arg_chunks->chunks[i].offset (2039586048) == updated_offsets[i] (2039586048)
[ PASS] 16.017 cf_chunk_tests.c:588 - arg_chunks->chunks[i].size (388822370) == updated_sizes[i] (388822370)
[ PASS] 16.018 cf_chunk_tests.c:586 - arg_chunks->chunks[i].offset (611348629) == updated_offsets[i] (611348629)
[ PASS] 16.019 cf_chunk_tests.c:588 - arg_chunks->chunks[i].size (863016801) == updated_sizes[i] (863016801)
[ PASS] 16.020 cf_chunk_tests.c:586 - arg_chunks->chunks[i].offset (1571317798) == updated_offsets[i] (1571317798)
[ PASS] 16.021 cf_chunk_tests.c:588 - arg_chunks->chunks[i].size (96336828) == updated_sizes[i] (96336828)
[ FAIL] 16.022 cf_chunk_tests.c:586 - arg_chunks->chunks[i].offset (790258762) == updated_offsets[i] (847905902)
[ FAIL] 16.023 cf_chunk_tests.c:588 - arg_chunks->chunks[i].size (628830104) == updated_sizes[i] (1762369143)
[  END] 16 Test_CF_Chunks_InsertChunk_PutGiven_chu TOTAL::23    PASS::20    FAIL::3     MIR::0     TSF::0     TTF::0     WARN::0

To Reproduce Built on 32 bit system, ran the coverage-cf-cf_chunk-testrunner test repeatedly (maybe 3 errors in 10)?

Expected behavior No failures.

Code snips https://github.com/nasa/CF/blob/dafc8aeaaa5c21aa39ddc9f4348c13fbcb363834/unit-test/cf_chunk_tests.c#L533-L590

System observed on:

Additional context

Reporter Info Jacob Hageman - NASA/GSFC

skliper commented 2 years ago

The cause is due to a buffer overflow in the test. updated_offsets and updated_sizes are undersized at 10 where the initial count is up to 10 and 1 gets added. In the setup it'll write to the updated offsets up to initial_count + 1.

Really this is a problematic test, since it's random you only see the overflow in random results (likely not caught by a single static analysis run)... there's over 200 lines of test code to cover 13 lines of unit code with 1 decision and 2 conditions. There's 0 added value for random values in the results, and so on.

skliper commented 2 years ago

@astrogeco Looks like this was merged, why was it reopened?

astrogeco commented 2 years ago

Closing. I'm not sure why this keeps happening.