Hi,
I'm not super familiar with glib and currently have an issue with the
arrows cglib lib.
I have some C++ code that creates a subclass of RecordBatchReader
(test_stream), and returns it to some C code as a GArrowRecordBatchReader *.
If I run the same code in C++ it runs fine, but in C I always get a
segmentation fault when performing an operation on the returned
GArrowRecordBatchReader *.
test_stream doesn't really do anything other than return a dummy schema
(it's just a test).
Sample code:
*test_stream.h*
class test_stream: public ::arrow::RecordBatchReader {
public:
std::shared_ptr<::arrow::Schema> schema() const override {
return ::arrow::schema({::arrow::field("a", arrow::int32())});
}
arrow::Status ReadNext(std::shared_ptr<::arrow::RecordBatch> *batch)
override {
return arrow::Status::OK();
}
};
extern "C" GArrowRecordBatchReader* make_test_stream(){
std::shared_ptr<::arrow::RecordBatchReader> ts =
std::make_shared<test_stream>();
return garrow_record_batch_reader_new_raw(&ts);
}
*test.c (or test.cpp)*
GArrowRecordBatchReader *ts = make_test_stream();
GArrowSchema *schema = garrow_record_batch_reader_get_schema(ts); <----
segfault here
Underlying break happens in arrows reader.h on this piece of code...
#define GARROW_TYPE_RECORD_BATCH_READER
(garrow_record_batch_reader_get_type())
G_DECLARE_DERIVABLE_TYPE(GArrowRecordBatchReader,
garrow_record_batch_reader,
GARROW,
RECORD_BATCH_READER,
GObject)
It smells like its something to do with my sub classing of
RecordBatchReader but I don't know enough about glib.
Thanks, Matt