You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Rust version : rustc -V: rustc 1.66.1 (90743e729 2023-01-10)
nom version :
[[package]]
name = "nom"
version = "7.1.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "e5507769c4919c998e69e49c839d9dc6e693ede4cc4290d6ad8b41d4f09c548c"
nom compilation features used: none
Test case
I'm currently using an input based on &[u8] (coming from a binary file) but I want to display the VerboseError as a string since it's actually working on source code snippets. Consequently, I mapped over VerboseError{ error } member to convert the input of each level to a String before handing it to convert_error().
Problem: convert_error() assumes that the saved input in VerboseError { error } is simply a pointer inside the overall input, but in this case it's not at all true (overall input got converted to String, and so is every saved input in the stack). This results in a panic!() as the offset computation results in a negative usize:
3: <str as nom::traits::Offset>::offset
at /home/dourai01/.cargo/registry/src/github.com-1ecc6299db9ec823/nom-7.1.2/src/traits.rs:76:5
4: nom::error::convert_error
at /home/dourai01/.cargo/registry/src/github.com-1ecc6299db9ec823/nom-7.1.2/src/error.rs:261:18
5: traceevent::parser::tests::test_parser
at ./src/parser.rs:286:27
6: traceevent::cparser::tests::declaration_test::test
at ./src/cparser.rs:1683:13
Would it be possible to use a content-based offset detection rather than assuming all pointers point inside the same object ? It may be possible to do that as a fallback while the fast path still does pointer arithmetic, since it should be easy to check if the substring ptr is within the address range of the overall input.
The text was updated successfully, but these errors were encountered:
Prerequisites
rustc -V
:rustc 1.66.1 (90743e729 2023-01-10)
Test case
I'm currently using an input based on
&[u8]
(coming from a binary file) but I want to display theVerboseError
as a string since it's actually working on source code snippets. Consequently, I mapped overVerboseError{ error }
member to convert the input of each level to aString
before handing it toconvert_error()
.Problem:
convert_error()
assumes that the saved input inVerboseError { error }
is simply a pointer inside the overall input, but in this case it's not at all true (overall input got converted to String, and so is every saved input in the stack). This results in a panic!() as the offset computation results in a negative usize:Would it be possible to use a content-based offset detection rather than assuming all pointers point inside the same object ? It may be possible to do that as a fallback while the fast path still does pointer arithmetic, since it should be easy to check if the substring ptr is within the address range of the overall input.
The text was updated successfully, but these errors were encountered: