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 error message when elf_parser fails on long section names #537

Merged
merged 1 commit into from
Oct 6, 2023

Conversation

ksolana
Copy link

@ksolana ksolana commented Oct 2, 2023

Addresses: #532

With the patch error message now looks like:

failures:

---- test_sample stdout ----
thread 'test_sample' panicked at 'called `Result::unwrap()` on an `Err` value: ElfError(FailedToParse("Section/symbol name size `.bss.__rust_no_a` longer than `16`"))', tests/execution.rs:2211:5
stack backtrace:
   0: rust_begin_unwind
             at /rustc/d5c2e9c342b358556da91d61ed4133f6f50fc0c3/library/std/src/panicking.rs:593:5
   1: core::panicking::panic_fmt
             at /rustc/d5c2e9c342b358556da91d61ed4133f6f50fc0c3/library/core/src/panicking.rs:67:14
   2: core::result::unwrap_failed
             at /rustc/d5c2e9c342b358556da91d61ed4133f6f50fc0c3/library/core/src/result.rs:1651:5
   3: core::result::Result<T,E>::unwrap
             at /rustc/d5c2e9c342b358556da91d61ed4133f6f50fc0c3/library/core/src/result.rs:1076:23
   4: execution::test_sample
             at ./tests/execution.rs:2211:5
   5: execution::test_sample::{{closure}}
             at ./tests/execution.rs:2210:18
   6: core::ops::function::FnOnce::call_once
             at /rustc/d5c2e9c342b358556da91d61ed4133f6f50fc0c3/library/core/src/ops/function.rs:250:5
   7: core::ops::function::FnOnce::call_once
             at /rustc/d5c2e9c342b358556da91d61ed4133f6f50fc0c3/library/core/src/ops/function.rs:250:5
note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace.

tests/execution.rs Outdated Show resolved Hide resolved
src/elf_parser/mod.rs Outdated Show resolved Hide resolved
@codecov-commenter
Copy link

codecov-commenter commented Oct 3, 2023

Codecov Report

Merging #537 (f1f0042) into main (32b1a6f) will decrease coverage by 0.01%.
The diff coverage is 85.71%.

@@            Coverage Diff             @@
##             main     #537      +/-   ##
==========================================
- Coverage   88.41%   88.41%   -0.01%     
==========================================
  Files          24       24              
  Lines       10258    10264       +6     
==========================================
+ Hits         9070     9075       +5     
- Misses       1188     1189       +1     
Files Coverage Δ
src/elf_parser_glue.rs 68.53% <ø> (ø)
src/elf_parser/mod.rs 81.84% <85.71%> (+0.02%) ⬆️

@ksolana
Copy link
Author

ksolana commented Oct 4, 2023

let me know if it is okay to merge the patch.

tests/execution.rs Outdated Show resolved Hide resolved
@dmakarov
Copy link
Collaborator

dmakarov commented Oct 5, 2023

lgtm, but maybe confirm @Lichtso approves before merging.

@Lichtso
Copy link

Lichtso commented Oct 6, 2023

Took the liberty to push the following changes:

  • Used String::from_utf8_lossy() which uses replacement characters and can not fail, so we don't have to deal with UTF-8 errors.
  • Moved test_long_section_name from execution.rs to elf.rs as it is about ELF parsing.
  • Replaced #[should_panic()] with assert_error!() so we can programmatically cut the name to the desired length.
  • Renamed InvalidStringTooLong to just StringTooLong. InvalidString can be removed because it is only used inside a debug formater.

@dmakarov
Copy link
Collaborator

dmakarov commented Oct 6, 2023

Resolve #532

@ksolana ksolana merged commit 06e22d7 into solana-labs:main Oct 6, 2023
12 checks passed
@ksolana
Copy link
Author

ksolana commented Oct 6, 2023

Took the liberty to push the following changes:

* Used `String::from_utf8_lossy()` which uses replacement characters and can not fail, so we don't have to deal with UTF-8 errors.

* Moved `test_long_section_name` from execution.rs to elf.rs as it is about ELF parsing.

* Replaced `#[should_panic()]` with `assert_error!()` so we can programmatically cut the name to the desired length.

* Renamed `InvalidStringTooLong` to just `StringTooLong`. `InvalidString` can be removed because it is only used inside a debug formater.

Thanks! looks better now.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants