10000 Panic in parsing at lib/prometheus-parser · Issue #23042 · vectordotdev/vector · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content
8000

Panic in parsing at lib/prometheus-parser #23042

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

Open
wooffie opened this issue May 13, 2025 · 0 comments · May be fixed by #23077
Open

Panic in parsing at lib/prometheus-parser #23042

wooffie opened this issue May 13, 2025 · 0 comments · May be fixed by #23077
Labels
type: bug A code related bug.

Comments

@wooffie
Copy link
Contributor
wooffie commented May 13, 2025

A note for the community

  • Please vote on this issue by adding a 👍 reaction to the original issue to help the community and maintainers prioritize this request
  • If you are interested in working on this issue or have submitted a pull request, please leave a comment

Problem

By using public function parse_text we can get Panic. After minizing crash i found that it happens in function Metric::parse_timestamp.

Problem in handling unwrap() inside closure, i think in this place we should have another nom parser

Configuration


Version

latest from git - 9129d95

Debug Output

thread 'line::test::test_parse_timestamp' panicked at lib/prometheus-parser/src/line.rs:155:23:
called `Result::unwrap()` on an `Err` value: ParseIntError { kind: PosOverflow }
stack backtrace:
   0: rust_begin_unwind
             at /rustc/4eb161250e340c8f48f66e2b929ef4a5bed7c181/library/std/src/panicking.rs:692:5
   1: core::panicking::panic_fmt
             at /rustc/4eb161250e340c8f48f66e2b929ef4a5bed7c181/library/core/src/panicking.rs:75:14
   2: core::result::unwrap_failed
             at /rustc/4eb161250e340c8f48f66e2b929ef4a5bed7c181/library/core/src/result.rs:1704:5
   3: core::result::Result<T,E>::unwrap
             at /home/wooffie/.rustup/toolchains/1.85-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/result.rs:1109:23
   4: prometheus_parser::line::Metric::parse_timestamp::{{closure}}
             at ./src/line.rs:155:13
   5: nom::combinator::map::{{closure}}
             at /home/wooffie/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/nom-7.1.3/src/combinator/mod.rs:80:16
   6: <F as nom::internal::Parser<I,O,E>>::parse
             at /home/wooffie/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/nom-7.1.3/src/internal.rs:325:5
   7: nom::combinator::opt::{{closure}}
             at /home/wooffie/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/nom-7.1.3/src/combinator/mod.rs:245:11
   8: prometheus_parser::line::Metric::parse_timestamp
             at ./src/line.rs:154:9
   9: prometheus_parser::line::test::test_parse_timestamp
             at ./src/line.rs:667:20
  10: prometheus_parser::line::test::test_parse_timestamp::{{closure}}
             at ./src/line.rs:666:30
  11: core::ops::function::FnOnce::call_once
             at /home/wooffie/.rustup/toolchains/1.85-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/ops/function.rs:250:5
  12: core::ops::function::FnOnce::call_once
             at /rustc/4eb161250e340c8f48f66e2b929ef4a5bed7c181/library/core/src/ops/function.rs:250:5
note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace.

Example Data

Reproduce:

    #[test]
    fn test_parse_timestamp() {
        assert_eq!(Metric::parse_timestamp("9994997499749974749"), Ok(("", None))); // repro
        assert_eq!(Metric::parse_timestamp(""), Ok(("", None)));
        assert_eq!(Metric::parse_timestamp("123"), Ok(("", Some(123))));
        assert_eq!(Metric::parse_timestamp(" -23"), Ok(("", Some(-23))));
    }
cargo test --package prometheus-parser --lib -- line::test::test_parse_timestamp --exact --show-output

Additional Context

I'm some braintwisted with nom library and want help to fix this bug =(

Found by https://github.com/rust-fuzz/cargo-fuzz

References

No response

@wooffie wooffie added the type: bug A code related bug. label May 13, 2025
@wooffie wooffie linked a pull request May 20, 2025 that will close this issue
8 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type: bug A code related bug.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant
0