aptos-labs / aptos-core

Aptos is a layer 1 blockchain built to support the widespread use of blockchain through better technology and user experience.
https://aptosfoundation.org
Other
6.04k stars 3.61k forks source link

[Bug] `aptos move coverage source` panics when used on `features` module in `move-stdlib` #14360

Closed Rqnsom closed 2 weeks ago

Rqnsom commented 3 weeks ago

πŸ› Bug

While doing some research at Eiger for the extension of the move-spec-test project, I found a problem in the aptos move coverage command.

To reproduce

Code snippet to reproduce

cd aptos-core/aptos-move/framework/move-stdlib;
aptos move test --coverage;
aptos move coverage source --module features;

Stack trace/error message

$ aptos move coverage source --module features
thread 'main' panicked at third_party/move/tools/move-coverage/src/source_coverage.rs:194:69:
attempt to subtract with overflow
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace

Expected Behavior

The command shouldn't have crashed; instead, a coverage report for the features module should have been printed out.

System information

Additional context

N/A

rahxephon89 commented 3 weeks ago

Thanks for reporting this @Rqnsom. We will fix it soon.

brmataptos commented 3 weeks ago

FYI: This is due to traces for cross-module inline code being wrongly mapped to corresponding lines in the using module. Will first fix to disable this from happening, but add a flag to include the inline code coverage info (which will be more expensive to gather).

wrwg commented 3 weeks ago

We know that coverage for inline functions is broken (#9154, #12919) but not that this crashes the tool. Perhaps for compiler v2, we can finally fix this.