Comments (8)
It is invalid because it contains a section name longer than 16 bytes: .bss.__rust_no_alloc_shim_is_unstable
This should be easy to fix by merging all .bss*
sections into one called just .bss
in the linker script.
from rbpf.
The error message reports invalid string. This has to be fixed. Also a test case must be added, that checks the correct error reporting.
from rbpf.
Please don’t close issues that I open until I confirm that it is resolved.
from rbpf.
Roger,
What other error message would you expect? It is an invalid string after all. Or do you want a separate StringTooLong
error code?
from rbpf.
It’s not an invalid string. in this case the error message must inform that a section name is over the length limit and indicate which section it is. The string that it breaks on is not even the one of the section name. Fix this.
from rbpf.
Not saying it can't be done but it is tricky, hence we haven't implemented it yet.
You would have to retry the parsing with a much longer zero-termination-search but only on the error path, and also parse the UTF-8, both of which can fail leading to an exception during exception handling. Also, for the string in the error message you would need a heap allocation, which I just go rid of inside RBPF for the runtime (not parsing though).
from rbpf.
backtrace after applyhing the patch
diff --git a/tests/execution.rs b/tests/execution.rs
index bb2f9a9..5102e06 100644
--- a/tests/execution.rs
+++ b/tests/execution.rs
@@ -2206,6 +2206,17 @@ fn test_relative_call() {
);
}
+#[test]
+fn test_sample() {
+ test_interpreter_and_jit_elf!(
+ "tests/elfs/sample.so",
+ [1],
+ (),
+ TestContextObject::new(18),
+ ProgramResult::Ok(3),
+ );
+}
+
and cp sample.so tests/elfs/
---- test_sample stdout ----
thread 'test_sample' panicked at 'called `Result::unwrap()` on an `Err` value: ElfError(FailedToParse("invalid string"))', 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
from rbpf.
Reporting a more meaningful error (not the obscured "invalid string") definitely doesn't require any of "parsing with a much longer zero-termination-search", "parse the UTF-8", or "heap allocation". Even if the error includes the first 16 characters of the section name, it would be sufficient (no heap allocation needed, even though using heap allocation as an excuse for improper error reporting is non-withstanding). Finally, the current tests do not test the elf_parser on any ELF files that would be rejected. This is simply unacceptable.
from rbpf.
Related Issues (20)
- JIT: Emit Intel CET instructions HOT 5
- Consider renaming le16, le32, le64
- Disassemble example panics
- The new ELF parser should enforce the first section header to be SHT_NULL
- The new ELF Parser incorrectly reports sections as OutOfBounds if the section ends at the end of the ELF file
- The new ELF parser should use checked instead of saturating arithmetic
- elf: retrieve all dynamic metadata from the `.dynamic` table instead of requiring section headers
- JitCompiler::new() uses unwrap()
- Read only sections can overlap with the stack
- eBPF Standardization HOT 2
- Call target labels are not resolved in v0.2.38 HOT 4
- 32bit target support HOT 2
- ExceededMaxInstructions error message is confusing HOT 1
- Only require winapi on Windows
- git clone and cargo build gives error HOT 3
- Call instruction transfers control to incorrect address HOT 4
- RBPF is killed by the OS while running a program HOT 2
- make btf instruction class an enum
- Attempt to negate with overflow in disassembler
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from rbpf.