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

assertion error #43

Open
rpodgorny opened this issue Oct 24, 2022 · 1 comment
Open

assertion error #43

rpodgorny opened this issue Oct 24, 2022 · 1 comment

Comments

@rpodgorny
Copy link

rpodgorny commented Oct 24, 2022

hi, i'm trying to write a dbf file (from another dbf) and i keep failing with the following traceback:

thread 'main' panicked at 'assertion failed: `(left == right)`                                                                                              
  left: `7`,                                                                                                                                                                                   
 right: `6`': /home/radek/.cargo/registry/src/github.com-1ecc6299db9ec823/dbase-0.3.0/src/writing.rs:365                                                                                       
   0: <backtrace::capture::Backtrace as core::default::Default>::default                                                                                                                       
             at /home/radek/.cargo/registry/src/github.com-1ecc6299db9ec823/backtrace-0.3.66/src/capture.rs:410:9                                                                              
   1: log_panics::Config::install_panic_hook::{{closure}}                                                                                                                                      
             at /home/radek/.cargo/registry/src/github.com-1ecc6299db9ec823/log-panics-2.1.0/src/lib.rs:115:29                                                                                 
   2: std::panicking::rust_panic_with_hook
             at /rustc/a55dd71d5fb0ec5a6a3a9e8c27b2127ba491ce52/library/std/src/panicking.rs:702:17
   3: std::panicking::begin_panic_handler::{{closure}}
             at /rustc/a55dd71d5fb0ec5a6a3a9e8c27b2127ba491ce52/library/std/src/panicking.rs:588:13
   4: std::sys_common::backtrace::__rust_end_short_backtrace
             at /rustc/a55dd71d5fb0ec5a6a3a9e8c27b2127ba491ce52/library/std/src/sys_common/backtrace.rs:138:18
   5: rust_begin_unwind
             at /rustc/a55dd71d5fb0ec5a6a3a9e8c27b2127ba491ce52/library/std/src/panicking.rs:584:5
   6: core::panicking::panic_fmt
             at /rustc/a55dd71d5fb0ec5a6a3a9e8c27b2127ba491ce52/library/core/src/panicking.rs:142:14
   7: core::panicking::assert_failed_inner
   8: core::panicking::assert_failed
             at /rustc/a55dd71d5fb0ec5a6a3a9e8c27b2127ba491ce52/library/core/src/panicking.rs:181:5
   9: dbase::writing::FieldWriter<W>::write_next_field_value
             at /home/radek/.cargo/registry/src/github.com-1ecc6299db9ec823/dbase-0.3.0/src/writing.rs:365:13
  10: <dbase::reading::Record as dbase::writing::WritableRecord>::write_using
             at /home/radek/.cargo/registry/src/github.com-1ecc6299db9ec823/dbase-0.3.0/src/writing.rs:306:13
  11: dbase::writing::TableWriter<W>::write_record
             at /home/radek/.cargo/registry/src/github.com-1ecc6299db9ec823/dbase-0.3.0/src/writing.rs:488:9
  12: dbase::writing::TableWriter<W>::write_records
             at /home/radek/.cargo/registry/src/github.com-1ecc6299db9ec823/dbase-0.3.0/src/writing.rs:544:13
  13: mj191_tool::main
             at src/main.rs:80:5

(...it goes on but that's not interesting, i guess)

the code is basically this:

let mut reader = dbase::Reader::from_path(db_fn).unwrap();                                                                                             
let mut recs = reader.read().unwrap();                                                                      
let mut writer = dbase::TableWriterBuilder::from_reader(reader).build_with_file_dest("/tmp/test.dbf").unwrap();
writer.write_records(&recs).unwrap();

...what could be the cause?

thanks!

@tmontaigu
Copy link
Owner

Seems like its this debug_assert that is being hit

debug_assert_eq!(self.buffer.position(), field_info.field_length as u64);

Since its a debug assert it should not be possible to trigger it in release mode (cargo run --release), can you try to run your program in release mode and see if the generated file is still valid ?

The assert seems a bit restrictive, what you may see in the output file is some truncated values

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants