Skip to content

Panic when parsing message #25

@matt24smith

Description

@matt24smith

Hi, thanks for creating this library!

I encounter panic when trying to parse certain messages, an example of the issue is included as follows

use nmea_parser::NmeaParser;

fn parsemsg(sentence: &str) {
    let mut parser = NmeaParser::new();

    if let Ok(payload) = parser.parse_sentence(sentence) {
        println!("did not panic yet {:?}", payload);
    }
}

#[cfg(test)]
mod tests {
    use super::*;

    #[test]
    fn this_works() {
        let sentence = "!AIVDM,1,1,,,19NS8eP01t2rTJugUtmqOoVL00R@,0*53";
        parsemsg(sentence);
        let sentence2 = "!AIVDM,not,a,valid,nmea,string,0*00";
        parsemsg(sentence2);
    }

    #[test]
    fn this_panics() {
        let sentence = "!AIVDM,1,1,,,;ie05s`0Kk6UvFiQ`IaUfW3iC8pB,0*02";
        parsemsg(sentence);
    }
}

Produces output

running 2 tests
test errcheck::tests::this_works ... ok
test errcheck::tests::this_panics ... FAILED

failures:

---- errcheck::tests::this_panics stdout ----
thread 'errcheck::tests::this_panics' panicked at 'No such local time', /home/matt/.cargo/registry/src/github.com-1ecc6299db9ec823/chrono-0.4.19/src/offset/mod.rs:173:34
stack backtrace:
   0: std::panicking::begin_panic
             at /rustc/1.57.0/library/std/src/panicking.rs:543:12
   1: chrono::offset::LocalResult<T>::unwrap
             at /home/matt/.cargo/registry/src/github.com-1ecc6299db9ec823/chrono-0.4.19/src/offset/mod.rs:173:34
   2: chrono::offset::TimeZone::ymd
             at /home/matt/.cargo/registry/src/github.com-1ecc6299db9ec823/chrono-0.4.19/src/offset/mod.rs:214:9
   3: nmea_parser::ais::vdm_t11::handle
             at /home/matt/.cargo/registry/src/github.com-1ecc6299db9ec823/nmea-parser-0.8.0/src/ais/vdm_t11.rs:31:17
   4: nmea_parser::NmeaParser::parse_sentence
             at /home/matt/.cargo/registry/src/github.com-1ecc6299db9ec823/nmea-parser-0.8.0/src/lib.rs:577:31
   5: rust_aisdb_lib::errcheck::parsemsg
             at ./src/errcheck.rs:6:26
   6: rust_aisdb_lib::errcheck::tests::this_panics
             at ./src/errcheck.rs:26:9
   7: rust_aisdb_lib::errcheck::tests::this_panics::{{closure}}
             at ./src/errcheck.rs:24:5
   8: core::ops::function::FnOnce::call_once
             at /rustc/1.57.0/library/core/src/ops/function.rs:227:5
   9: core::ops::function::FnOnce::call_once
             at /rustc/1.57.0/library/core/src/ops/function.rs:227:5
note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace.


failures:
    errcheck::tests::this_panics

test result: FAILED. 1 passed; 1 failed; 0 ignored; 0 measured; 3 filtered out; finished in 0.06s

error: test failed, to rerun pass '--lib'

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions