This repository was archived by the owner on Feb 1, 2026. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 9
This repository was archived by the owner on Feb 1, 2026. It is now read-only.
GCC Linux Simple Example Using DataFile Core Dumps #9
Copy link
Copy link
Open
Description
Following the example for DataFile.cc (bottom of page) at: https://avro.apache.org/docs/current/api/cpp/html/index.html
The example runs fine on macos but on any gcc linux system (ubuntu 18.04, debian buster, etc) the program core dumps for uninitialized value. The target is linux.
I use conan to pull in the lib:
[requires]
libavrocpp/1.10.2
[generators]
cmake
I could really use some help on this. I don't see any other c++ solutions and the client is in need.
dbh-vm :: CLionProjects/AvroLastChance/cmake-build-debug » valgrind ./bin/AvroLastChance
139 ↵
==42562== Memcheck, a memory error detector
==42562== Copyright (C) 2002-2017, and GNU GPL'd, by Julian Seward et al.
==42562== Using Valgrind-3.18.1 and LibVEX; rerun with -h for copyright info
==42562== Command: ./bin/AvroLastChance
==42562==
==42562== Use of uninitialised value of size 8
==42562== at 0x11B0B2: avro::codec_traits<double>::encode(avro::Encoder&, double) (Specific.hh:151)
==42562== by 0x11B214: void avro::encode<double>(avro::Encoder&, double const&) (Specific.hh:332)
==42562== by 0x11B11C: avro::codec_traits<c::cpx>::encode(avro::Encoder&, c::cpx const&) (cpx.hh:44)
==42562== by 0x11B51C: void avro::encode<c::cpx>(avro::Encoder&, c::cpx const&) (Specific.hh:332)
==42562== by 0x11B37B: avro::DataFileWriter<c::cpx>::write(c::cpx const&) (DataFile.hh:166)
==42562== by 0x11AF7E: test2() (main.cpp:52)
==42562== by 0x11AEE0: main (main.cpp:39)
Schema (generated the cpx.hh with avrogencpp tool): avrogencpp -i cpx.json -o cpx.hh -n c
{
"type": "record",
"name": "cpx",
"fields" : [
{
"name": "re",
"type": "double"
},
{
"name": "im",
"type" : "double"
}
]
}
Code:
#include <iostream>
#include "cpx.hh"
#include "avro/Encoder.hh"
#include "avro/Decoder.hh"
#include "avro/ValidSchema.hh"
#include "avro/Compiler.hh"
#include "avro/DataFile.hh"
#include <fstream>
avro::ValidSchema loadSchema(const char* filename)
{
std::ifstream ifs(filename);
avro::ValidSchema result;
avro::compileJsonSchema(ifs, result);
return result;
}
int main()
{
avro::ValidSchema cpxSchema = loadSchema("cpx.json");
{
avro::DataFileWriter<c::cpx> dfw("test.avro", cpxSchema);
c::cpx c1;
for (int i = 0; i < 100; i++) {
c1.re = i * 100;
c1.im = i + 100;
dfw.write(c1);
}
dfw.close();
}
return 0;
}
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels