sk337
August 22, 2024, 2:30pm
1
could a compiler option in the panic arg called drop be added that will work similarly to abort but will also remove the panic messages themself so they are not in the binary itself only way i can think of to do this would be going into the binary and replacing all the panic message strings with random strings
pitaj
August 22, 2024, 3:19pm
2
Does panic_immediate_abort
not cover your use case?
bjorn3
August 22, 2024, 9:45pm
3
Are you the person who opened
opened 08:00PM - 20 Aug 24 UTC
I-prioritize
regression-untriaged
A-panic
C-optimization
### Code
Code is minimized as much as possible and here is a demo repository:… https://github.com/StackOverflowExcept1on/rust-regression
- `wasm-program` - this is smart contract that panics and terminates with an error
- `wasm-project` - some intermediate directory that is generated by our utility
```bash
git clone https://github.com/StackOverflowExcept1on/rust-regression.git
cd rust-regression/wasm-project
./check.sh
```
```
/home/user/rust-regression/wasm-project
Compiling rustversion v1.0.17
Compiling arrayvec v0.7.6
Compiling wasm-program v0.1.0 (/home/user/rust-regression/wasm-program)
Compiling wasm-project v0.1.0 (/home/user/rust-regression/wasm-project)
Finished `release` profile [optimized] target(s) in 0.59s
grep: ./target/wasm32-unknown-unknown/release/wasm_program.wasm: binary file matches
/home/user/... found in WASM :(
```
I expected to see this happen: *`/home/user/...` removed from wasm*
Instead, this happened: *`/home/user/...` is not removed from wasm*
We want `/home/user/...` to always be removed from smart contracts, otherwise it reveals some information about creator name and also increases cost of uploading to blockchain. We tried using `--remap-path-prefix`, but it results in longer build times. On the old version, rustc compiler was so smart that it figured out how to remove all panic locations from the binary file.
Maybe related to #115974, but I haven't checked every commit. Although it is worth noting that #115974 is very useful as we can get panic message and remove panic location in stable rust.
### Version it worked on
It most recently worked on: `nightly-2024-06-12`
```
$ rustc +nightly-2024-06-12 --version --verbose
rustc 1.81.0-nightly (d0227c6a1 2024-06-11)
binary: rustc
commit-hash: d0227c6a19c2d6e8dceb87c7a2776dc2b10d2a04
commit-date: 2024-06-11
host: x86_64-unknown-linux-gnu
release: 1.81.0-nightly
LLVM version: 18.1.7
```
### Version with regression
Starting from `nightly-2024-06-13`, behavior has changed
```
$ rustc +nightly-2024-06-13 --version --verbose
rustc 1.81.0-nightly (8337ba918 2024-06-12)
binary: rustc
commit-hash: 8337ba9189de188e2ed417018af2bf17a57d51ac
commit-date: 2024-06-12
host: x86_64-unknown-linux-gnu
release: 1.81.0-nightly
LLVM version: 18.1.7
```
? I've given you several options that should work there. If they all don't work for you, please tell us why they don't work. Also in the future please make clear when you are cross-posting.