Skip to content
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

pest2ion Tool Cannot Generate Pretty/Compact Text for PartiQL Grammar #43

Closed
almann opened this issue Jun 10, 2021 · 1 comment
Closed
Labels
bug Something isn't working

Comments

@almann
Copy link
Contributor

almann commented Jun 10, 2021

This is probably an upstream bug with ion-rs/ion-c-sys, but when serializing the PartiQL grammar, we get an unexpected EOF:

Binary:

❯ cargo run --package pest-ion --bin pest2ion -- partiql-parser/src/peg/partiql.pest -b | wc -c
    Finished dev [unoptimized + debuginfo] target(s) in 0.02s
     Running `target/debug/pest2ion partiql-parser/src/peg/partiql.pest -b`
14897

Text:

❯ RUST_BACKTRACE=1 cargo run --package pest-ion --bin pest2ion -- partiql-parser/src/peg/partiql.pest -t | wc -c
    Finished dev [unoptimized + debuginfo] target(s) in 0.02s
     Running `target/debug/pest2ion partiql-parser/src/peg/partiql.pest -t`
thread 'main' panicked at 'called `Result::unwrap()` on an `Err` value: IonCError { code: 20, message: "IERR_UNEXPECTED_EOF", additional: "iERR Result" }', /home/ANT.AMAZON.COM/almann/.cargo/registry/src/github.aaakk.us.kg-1ecc6299db9ec823/ion-c-sys-0.4.10/src/writer.rs:612:50
stack backtrace:
   0: rust_begin_unwind
             at /rustc/9bc8c42bb2f19e745a63f3445f1ac248fb015e53/library/std/src/panicking.rs:493:5
   1: core::panicking::panic_fmt
             at /rustc/9bc8c42bb2f19e745a63f3445f1ac248fb015e53/library/core/src/panicking.rs:92:14
   2: core::option::expect_none_failed
             at /rustc/9bc8c42bb2f19e745a63f3445f1ac248fb015e53/library/core/src/option.rs:1329:5
   3: core::result::Result<T,E>::unwrap
             at /home/ANT.AMAZON.COM/almann/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/result.rs:1037:23
   4: <ion_c_sys::writer::IonCWriterHandle as core::ops::drop::Drop>::drop
             at /home/ANT.AMAZON.COM/almann/.cargo/registry/src/github.aaakk.us.kg-1ecc6299db9ec823/ion-c-sys-0.4.10/src/writer.rs:612:13
   5: core::ptr::drop_in_place<ion_c_sys::writer::IonCWriterHandle>
             at /home/ANT.AMAZON.COM/almann/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/ptr/mod.rs:187:1
   6: core::ptr::drop_in_place<ion_rs::value::writer::IonCSliceElementWriter>
             at /home/ANT.AMAZON.COM/almann/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/ptr/mod.rs:187:1
   7: pest2ion::main
             at ./pest-ion/src/bin/pest2ion/main.rs:82:1
   8: core::ops::function::FnOnce::call_once
             at /home/ANT.AMAZON.COM/almann/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/ops/function.rs:227:5
note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace.
0

The problem seems to be around the cleanup of the writer handle (the panic is happening during the cleanup of the Ion C writer.

@almann almann added the bug Something isn't working label Jun 10, 2021
@almann
Copy link
Contributor Author

almann commented Jun 10, 2021

Using the ion-cli:

❯ cargo install ion-cli && cargo run --package pest-ion --bin pest2ion -- partiql-parser/src/peg/partiql.pest -b | ion dump -f pretty | tail
    Updating crates.io index
     Ignored package `ion-cli v0.1.1` is already installed, use --force to override
    Finished dev [unoptimized + debuginfo] target(s) in 0.02s
     Running `target/debug/pest2ion partiql-parser/src/peg/partiql.pest -b`
{
  error_type: WRITE,
  message: "/home/ANT.AMAZON.COM/almann/.cargo/registry/src/github.aaakk.us.kg-1ecc6299db9ec823/ion-cli-0.1.1/ion-c/tools/events/ion_event_stream.cpp:1181 : IERR_NO_MEMORY",
  location: "stdin",
  event_index: 1688
}
                                                                        choice
                                                                        (
                                                                          choice
                                                                          (
                                                                            choice
                                                                            (
                                                                              choice
                                                                              (
                                                                                choice
                                                                                %  

Looks like Ion C's writer is getting hung up on the very deeply nested choice nodes. #37 should alleviate this, but there is still a bug in Ion C here.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants