lcov fails to generate coverage statistics in some configurations #226

Open
opened 2025-10-17 05:54:54 -05:00 by bjwtaylor · 1 comment
bjwtaylor commented 2025-10-17 05:54:54 -05:00 (Migrated from github.com)

Description

When the lcov.sh script is run with certain configurations most notably scripts/config.py full is fails to generate the coverage statistics with the following error:

geninfo: WARNING: <SRC>/tf-psa-crypto/drivers/builtin/src/lmots.c:152: unexecuted block on non-branch line with non-zero hit count.  Use "geninfo --rc geninfo_unexecuted_blocks=1 to set count to zero.
        (use "geninfo --ignore-errors gcov,gcov ..." to suppress this warning)
Processing tf-psa-crypto/drivers/builtin/CMakeFiles/builtin.dir/src/ecp_curves.c.gcda
geninfo: ERROR: Unexpected negative count '-10150' for branch 3 of <SRC>/tf-psa-crypto/drivers/builtin/src/ecp_curves.c:4499.
        Perhaps you need to compile with '-fprofile-update=atomic
        (use "geninfo --ignore-errors negative ..." to bypass this error)

Environment

This bug is present in the 1.0/4.0 release, however it is likely to be present in other versions.

The message above is on Ubuntu 24.04 x86_64.

Steps to reproduce

cmake -D CMAKE_BUILD_TYPE=Coverage <SRC>
dd if=/dev/urandom of=./tf-psa-crypto/tests/seedfile bs=64 count=1
dd if=/dev/urandom of=./tests/seedfile bs=64 count=1
scripts/config.py full
make;make test
<SRC>/framework/scripts/lcov.sh

Expected result vs. actual result

It is expected that the coverage data generation should succeed with no error's, however the following is generated.

geninfo: WARNING: <SRC>/tf-psa-crypto/drivers/builtin/src/lmots.c:152: unexecuted block on non-branch line with non-zero hit count.  Use "geninfo --rc geninfo_unexecuted_blocks=1 to set count to zero.
        (use "geninfo --ignore-errors gcov,gcov ..." to suppress this warning)
Processing tf-psa-crypto/drivers/builtin/CMakeFiles/builtin.dir/src/ecp_curves.c.gcda
geninfo: ERROR: Unexpected negative count '-10150' for branch 3 of <SRC>/tf-psa-crypto/drivers/builtin/src/ecp_curves.c:4499.
        Perhaps you need to compile with '-fprofile-update=atomic
        (use "geninfo --ignore-errors negative ..." to bypass this error)
**Description** When the lcov.sh script is run with certain configurations most notably scripts/config.py full is fails to generate the coverage statistics with the following error: ``` geninfo: WARNING: <SRC>/tf-psa-crypto/drivers/builtin/src/lmots.c:152: unexecuted block on non-branch line with non-zero hit count. Use "geninfo --rc geninfo_unexecuted_blocks=1 to set count to zero. (use "geninfo --ignore-errors gcov,gcov ..." to suppress this warning) Processing tf-psa-crypto/drivers/builtin/CMakeFiles/builtin.dir/src/ecp_curves.c.gcda geninfo: ERROR: Unexpected negative count '-10150' for branch 3 of <SRC>/tf-psa-crypto/drivers/builtin/src/ecp_curves.c:4499. Perhaps you need to compile with '-fprofile-update=atomic (use "geninfo --ignore-errors negative ..." to bypass this error) ``` **Environment** This bug is present in the 1.0/4.0 release, however it is likely to be present in other versions. The message above is on Ubuntu 24.04 x86_64. **Steps to reproduce** ``` cmake -D CMAKE_BUILD_TYPE=Coverage <SRC> dd if=/dev/urandom of=./tf-psa-crypto/tests/seedfile bs=64 count=1 dd if=/dev/urandom of=./tests/seedfile bs=64 count=1 scripts/config.py full make;make test <SRC>/framework/scripts/lcov.sh ``` **Expected result vs. actual result** It is expected that the coverage data generation should succeed with no error's, however the following is generated. ``` geninfo: WARNING: <SRC>/tf-psa-crypto/drivers/builtin/src/lmots.c:152: unexecuted block on non-branch line with non-zero hit count. Use "geninfo --rc geninfo_unexecuted_blocks=1 to set count to zero. (use "geninfo --ignore-errors gcov,gcov ..." to suppress this warning) Processing tf-psa-crypto/drivers/builtin/CMakeFiles/builtin.dir/src/ecp_curves.c.gcda geninfo: ERROR: Unexpected negative count '-10150' for branch 3 of <SRC>/tf-psa-crypto/drivers/builtin/src/ecp_curves.c:4499. Perhaps you need to compile with '-fprofile-update=atomic (use "geninfo --ignore-errors negative ..." to bypass this error) ```
gilles-peskine-arm commented 2025-10-17 06:03:25 -05:00 (Migrated from github.com)

Given the suggestion from geninfo, and the fact that this happens in the full config but not in the default config, it's likely that the problem is that we're using instrumentation that is not thread safe even when we run multithreaded tests.

That means that the coverage report that we get from basic-build-test.sh is probably wrong. The CI still runs basic-build-test.sh on Ubuntu 16.04. I suspect that the reason it doesn't error out is that this tool version is old and doesn't recognize the problem.

Given the suggestion from `geninfo`, and the fact that this happens in the full config but not in the default config, it's likely that the problem is that we're using instrumentation that is not thread safe even when we run multithreaded tests. That means that the coverage report that we get from `basic-build-test.sh` is probably wrong. The CI still runs `basic-build-test.sh` on Ubuntu 16.04. I suspect that the reason it doesn't error out is that this tool version is old and doesn't recognize the problem.
Sign in to join this conversation.
No milestone
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
gh-Mbed-TLS/mbedtls-framework#226
No description provided.