Skip to content
This repository has been archived by the owner on Jan 13, 2025. It is now read-only.

code coverage doesn't see constructors, other lines with hidden panic code #2367

Closed
rob-solana opened this issue Jan 9, 2019 · 6 comments
Closed
Labels
stale [bot only] Added to stale content; results in auto-close after a week.
Milestone

Comments

@rob-solana
Copy link
Contributor

Problem

code coverage doesn't see constructors, other lines with hidden panic code, resulting in wrongish coverage metrics, weird artifacts like very basic code (Poh::new()) not being in the "covered" space...

https://codecov.io/gh/solana-labs/solana/src/master/src/poh.rs

rust-lang/rust#55352

Rustc adds line-number information for unhittable panic handlers ...

Proposed Solution

??

@garious garious added this to the The Future! milestone Jan 9, 2019
@garious
Copy link
Contributor

garious commented Jan 9, 2019

My understanding is that a panic handler called a landing pad is implicitly added by default and that the way to disable it is passing rustc the -Z no-landing-pads. This test demonstrates how it works: https://github.com/rust-lang/rust/blob/master/src/test/run-pass/no-landing-pads.rs

@rob-solana says he experimented with add that flag after -Zprofile here: https://github.com/solana-labs/solana/blob/master/scripts/coverage.sh#L16, but didn't see any change in coverage.

I think we need to find a way to see what code is being generated with and without that flag to ensure it's not dropped by the Rust toolchain somewhere along the way.

@garious
Copy link
Contributor

garious commented Jan 9, 2019

@jackcmay, not a super high priority, but can you keep this one on your radar?

@garious
Copy link
Contributor

garious commented Jan 10, 2019

Another promising flag: -C panic=abort

@bossmc
Copy link

bossmc commented Feb 6, 2019

A warning, disabling landing pads breaks some other things (e.g. #[expect_panic] tests, and thread death reporting). Maybe that's fine for your use case, but you should be aware 😄.

@stale
Copy link

stale bot commented Sep 16, 2020

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs.

@stale stale bot added the stale [bot only] Added to stale content; results in auto-close after a week. label Sep 16, 2020
@stale
Copy link

stale bot commented Sep 24, 2020

This stale issue has been automatically closed. Thank you for your contributions.

@stale stale bot closed this as completed Sep 24, 2020
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Apr 3, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
stale [bot only] Added to stale content; results in auto-close after a week.
Projects
None yet
Development

No branches or pull requests

3 participants