redsift / rkdb

kdb+ Rust embedding and IPC
MIT License
17 stars 6 forks source link

Failure parsing table #13

Closed ajayrathore closed 4 years ago

ajayrathore commented 4 years ago

Hi Guys,

Apologies if the issue I am reporting turns out not to be an issue!

I have been trying to leverage your project as a layer on top of rust avro lib "avro_rs". End goal is to be able to parse avro messages coming over kafka from within kdb. I am able to encode/decode mixed lists successfully but encountered following issue while trying to parse a table.

Here is my simple rust function pub extern "C" fn encode_avro_tbl(k: *const K) -> () { match KVal::new(k) { KVal::Table(b) => println!("Found table {:?}", b), _ => println!("No match") }; }

After I build this and try to use in q, I get following seg fault

q)encode:librkdbavro 2:(encode_avro_tbl;1) q)t:([]sid:5?100i; sym:5?2;price:5?10f;size:5?100) q)t sid sym price size

88 pl 7.85033 12 58 nn 5.347096 10 68 gl 7.111716 1 45 gk 4.11597 90 2 bg 4.931835 73 q) q)meta t c t f a
sid i
sym s
price f
size j

q) q)encode[t] thread '' panicked at 'byte index 88 is not a char boundary; it is inside '\u{0}' (bytes 87..88) of sid P)�9 ��**�E��E��F�����[...]', src/libcore/str/mod.rs:2133:5 stack backtrace: 0: ::fmt 1: core::fmt::write 2: std::io::Write::write_fmt 3: std::panicking::default_hook::{{closure}} 4: std::panicking::default_hook 5: std::panicking::rust_panic_with_hook 6: rust_begin_unwind 7: core::panicking::panic_fmt 8: core::str::slice_error_fail 9: core::str::traits::<impl core::slice::SliceIndex for core::ops::range::Range>::index::{{closure}} 10: ::fmt 11: core::fmt::builders::DebugInner::entry 12: core::fmt::builders::DebugList::entry 13: <&T as core::fmt::Debug>::fmt 14: core::fmt::builders::DebugTuple::field 15: <&T as core::fmt::Debug>::fmt 16: core::fmt::builders::DebugTuple::field 17: ::fmt 18: core::fmt::builders::DebugTuple::field 19: ::fmt 20: core::fmt::write 21: ::write_fmt 22: std::io::stdio::_print 23: encode_avro_tbl 24: dl 25: setSysNotify 26: setSysNotify 27: setSysNotify 28: setSysNotify 29: setSysNotify 30: m9 31: knt 32: 33: sd1 34: sd1 35: dl note: Some details are omitted, run with RUST_BACKTRACE=full for a verbose backtrace. fatal runtime error: failed to initiate panic, error 5 q: warning: q crashed, killed by SIGABRT. q itself has not crashed, but for transparency, it will now kill itself (without dumping core) with the same signal `

Is it an issue or am I using it incorrectly? I would really appreciate any help.

Thanks, Ajay

ajayrathore commented 4 years ago

Closing the issue, seems like seg fault was coming from the print macro