Skip to content

Crash in EN for inputs of the form "<big_number> <nth> quarter" #184

Closed
@adrienball

Description

Parsing Error

rustling crashes when called with inputs of the form "<number> <nth> quarter" where <number> is a number greater than 1050000 and <nth> is an ordinal (1st, 2nd, 3rd ...).

The crash doesn't happend for <number> values smaller than 1040000, however the closer to 1040000 and the longer the parsing time is. On my Macbook Pro (Core i7), the parsing time goes up to 1m45s for 1040000.

Version

0.18.1

Language

en

Parser input

1050000 2nd quarter

Parser output

$ RUST_BACKTRACE=1 cargo run -p rustling-cli -- --lang en parse "1050000 2nd quarter"                                                                                 101 ↵
    Finished dev [unoptimized + debuginfo] target(s) in 0.17s
     Running `target/debug/rustling-cli --lang en parse '1050000 2nd quarter'`
thread 'main' panicked at 'No such local time', /Users/adrien/.cargo/registry/src/github.com-1ecc6299db9ec823/chrono-0.4.6/src/offset/mod.rs:145:34
stack backtrace:
   0: std::sys::unix::backtrace::tracing::imp::unwind_backtrace
             at src/libstd/sys/unix/backtrace/tracing/gcc_s.rs:39
   1: std::sys_common::backtrace::_print
             at src/libstd/sys_common/backtrace.rs:70
   2: std::panicking::default_hook::{{closure}}
             at src/libstd/sys_common/backtrace.rs:58
             at src/libstd/panicking.rs:200
   3: std::panicking::default_hook
             at src/libstd/panicking.rs:215
   4: <std::panicking::begin_panic::PanicPayload<A> as core::panic::BoxMeUp>::get
             at src/libstd/panicking.rs:478
   5: std::sync::once::Once::is_completed
             at /rustc/2aa4c46cfdd726e97360c2734835aa3515e8c858/src/libstd/panicking.rs:412
   6: alloc::raw_vec::alloc_guard
             at ./<::std::macros::panic macros>:3
   7: core::ptr::real_drop_in_place
             at /Users/adrien/.cargo/registry/src/github.com-1ecc6299db9ec823/chrono-0.4.6/src/offset/mod.rs:186
   8: <time::duration::Duration as core::cmp::PartialOrd>::lt
             at moment/src/lib.rs:122
   9: <time::duration::Duration as core::cmp::PartialOrd>::lt
             at moment/src/lib.rs:186
  10: <time::duration::Duration as core::cmp::PartialOrd>::lt
             at moment/src/lib.rs:177
  11: rustling_ontology_values::helpers::easter::offset
             at ./moment/src/lib.rs:352
  12: core::clone::impls::<impl core::clone::Clone for usize>::clone
             at ./moment/src/interval_constraints.rs:675
  13: <bool as core::default::Default>::default
             at ./moment/src/walker.rs:146
  14: <bool as core::default::Default>::default
             at ./moment/src/walker.rs:233
  15: core::clone::impls::<impl core::clone::Clone for usize>::clone
             at ./moment/src/interval_constraints.rs:857
  16: core::clone::impls::<impl core::clone::Clone for usize>::clone
             at ./moment/src/interval_constraints.rs:1032
  17: <bool as core::default::Default>::default
             at ./moment/src/walker.rs:169
  18: <bool as core::default::Default>::default
             at ./moment/src/walker.rs:201
  19: <bool as core::default::Default>::default
             at ./moment/src/walker.rs:266
  20: <alloc::string::String as core::ops::deref::Deref>::deref
             at /rustc/2aa4c46cfdd726e97360c2734835aa3515e8c858/src/liballoc/vec.rs:1813
  21: <alloc::string::String as core::ops::deref::Deref>::deref
             at /rustc/2aa4c46cfdd726e97360c2734835aa3515e8c858/src/liballoc/vec.rs:1725
  22: <bool as core::default::Default>::default
             at /rustc/2aa4c46cfdd726e97360c2734835aa3515e8c858/src/libcore/iter/iterator.rs:1468
  23: core::clone::impls::<impl core::clone::Clone for usize>::clone
             at ./moment/src/interval_constraints.rs:1034
  24: core::clone::impls::<impl core::clone::Clone for usize>::clone
             at ./moment/src/interval_constraints.rs:864
  25: <alloc::collections::CollectionAllocErr as core::convert::From<core::alloc::AllocErr>>::from
             at values/src/context.rs:54
  26: <rustling_ontology::tagger::CandidateTagger<'a, C> as rustling::MaxElementTagger<rustling_ontology_values::dimension::Dimension>>::tag::{{closure}}
             at src/tagger.rs:62
  27: <alloc::collections::CollectionAllocErr as core::convert::From<core::alloc::LayoutErr>>::from
             at /rustc/2aa4c46cfdd726e97360c2734835aa3515e8c858/src/libcore/iter/mod.rs:1447
  28: <f32 as core::ops::arith::Mul<&'a f32>>::mul
             at /rustc/2aa4c46cfdd726e97360c2734835aa3515e8c858/src/libcore/iter/traits.rs:582
  29: core::hint::unreachable_unchecked
             at /rustc/2aa4c46cfdd726e97360c2734835aa3515e8c858/src/libcore/iter/traits.rs:519
  30: core::hint::unreachable_unchecked
             at /rustc/2aa4c46cfdd726e97360c2734835aa3515e8c858/src/libcore/iter/traits.rs:582
  31: <alloc::collections::CollectionAllocErr as core::convert::From<core::alloc::LayoutErr>>::from
             at /rustc/2aa4c46cfdd726e97360c2734835aa3515e8c858/src/libcore/iter/mod.rs:436
  32: <alloc::collections::CollectionAllocErr as core::convert::From<core::alloc::LayoutErr>>::from
             at /rustc/2aa4c46cfdd726e97360c2734835aa3515e8c858/src/libcore/iter/mod.rs:1447
  33: <alloc::collections::CollectionAllocErr as core::convert::From<core::alloc::LayoutErr>>::from
             at /rustc/2aa4c46cfdd726e97360c2734835aa3515e8c858/src/libcore/iter/iterator.rs:606
  34: core::hint::unreachable_unchecked
             at /rustc/2aa4c46cfdd726e97360c2734835aa3515e8c858/src/liballoc/vec.rs:1856
  35: core::hint::unreachable_unchecked
             at /rustc/2aa4c46cfdd726e97360c2734835aa3515e8c858/src/liballoc/vec.rs:1839
  36: core::hint::unreachable_unchecked
             at /rustc/2aa4c46cfdd726e97360c2734835aa3515e8c858/src/liballoc/vec.rs:1725
  37: <alloc::collections::CollectionAllocErr as core::convert::From<core::alloc::LayoutErr>>::from
             at /rustc/2aa4c46cfdd726e97360c2734835aa3515e8c858/src/libcore/iter/iterator.rs:1468
  38: core::hint::unreachable_unchecked
             at src/tagger.rs:60
  39: <alloc::collections::CollectionAllocErr as core::convert::From<core::alloc::LayoutErr>>::from
             at /Users/adrien/.cargo/git/checkouts/rustling-281bdd3bf97d4e1e/fd8084b/src/lib.rs:140
  40: <alloc::collections::CollectionAllocErr as core::convert::From<core::alloc::LayoutErr>>::from
             at /Users/adrien/.cargo/git/checkouts/rustling-281bdd3bf97d4e1e/fd8084b/src/lib.rs:144
  41: rustling_ontology::Parser
             at src/lib.rs:64
  42: rustling_ontology::Parser
             at src/lib.rs:89
  43: rustling_cli::main
             at cli/src/main.rs:54
  44: std::rt::lang_start::{{closure}}
             at /rustc/2aa4c46cfdd726e97360c2734835aa3515e8c858/src/libstd/rt.rs:64
  45: std::panicking::try::do_call
             at src/libstd/rt.rs:49
             at src/libstd/panicking.rs:297
  46: panic_unwind::dwarf::eh::read_encoded_pointer
             at src/libpanic_unwind/lib.rs:92
  47: <std::panicking::begin_panic::PanicPayload<A> as core::panic::BoxMeUp>::get
             at src/libstd/panicking.rs:276
             at src/libstd/panic.rs:388
             at src/libstd/rt.rs:48
  48: std::rt::lang_start
             at /rustc/2aa4c46cfdd726e97360c2734835aa3515e8c858/src/libstd/rt.rs:64
  49: rustling_cli::main

Parser expected output (Optional)

$ RUST_BACKTRACE=1 cargo run -p rustling-cli -- --lang en parse "1050000 2nd quarter"                                                                                    101 ↵
    Finished dev [unoptimized + debuginfo] target(s) in 0.14s
     Running `target/debug/rustling-cli --lang en parse '1050000 2nd quarter'`
+----+-------------+------------+------------------+---------------------------------------------------------------------------------------------------------+
| ix | log(p)      | p          | text             | value                                                                                                   |
+====+=============+============+==================+=========================================================================================================+
| 1  | -0.07018268 | 0.9322235  | 1050000_________ | Integer(IntegerOutput(1050000))                                                                         |
+----+-------------+------------+------------------+---------------------------------------------------------------------------------------------------------+
| 0  | -0.6190392  | 0.53846157 | _____2nd quarter | Time(TimeOutput { moment: 2019-04-01T00:00:00+02:00, grain: Quarter, precision: Exact, latent: false }) |
+----+-------------+------------+------------------+---------------------------------------------------------------------------------------------------------+

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions