Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add #[track_caller] to low-level functions #1645

Open
ethanfrey opened this issue Mar 22, 2023 · 0 comments
Open

Add #[track_caller] to low-level functions #1645

ethanfrey opened this issue Mar 22, 2023 · 0 comments
Labels
dev-experience improvements to DevX

Comments

@ethanfrey
Copy link
Member

ethanfrey commented Mar 22, 2023

When Rust panics, the #[track_caller] directive on a function ensures the stack trace is not reported.

Since we only return the last line of the stack when a contract aborts in wasm, we want it to be an important one. I often have seen a subtraction underflow on src/math.rs: 128 or such. Which tells me where in the cosmwasm-std it panics (obvious from the message), but nothing about where in the contract it was.

It would be good to investigate if #[track_caller] plays well with our abort callback and if so, add this to some lower-level math functions that panic, so we are likely to get a contract line number on math errors, not internal lines.

BTW, I took a look at the rust docs to see how this would affect the wasm panic handler and was left confused and amazed once again at the complexity of the rust compiler.

@chipshort chipshort added the dev-experience improvements to DevX label Sep 5, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
dev-experience improvements to DevX
Projects
None yet
Development

No branches or pull requests

2 participants