[
https://issues.apache.org/jira/browse/AVRO-2202?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16562161#comment-16562161
]
Josh Scoggins commented on AVRO-2202:
-------------------------------------
Well the corruption is the same each time we ran our unit tests. In fact, it is
a simple empty case where we just construct the object empty and then save it
to disk. Our structure is recursive so that may also contribute to this issue.
Here is the sample code snippet that _should_ exhibit the issue.
{code:c++}
template<typename T>
void saveObject(const T& object, const std::string& path, byte* schemaData,
unsigned schemaLen) {
avro::ValidSchema cpxSchema = avro::compileJsonSchemaFromMemory(schemaData,
schemaLen);
avro::DataFileWriter<T> writer(file.c_str(), cpxSchema, 16 * 1024, NULL_CODEC);
// in 1.8.2 the construction contains setMetadata which causes the issue
writer.write(object);
writer.flush();
writer.close();
// at the end of the function during the destruction of writer is where the
crash happens on master
}{code}
> Use of -fstack-protector or -D_GLIBCXX_DEBUG causes memory corruption when
> combined with musl libc static builds
> ----------------------------------------------------------------------------------------------------------------
>
> Key: AVRO-2202
> URL: https://issues.apache.org/jira/browse/AVRO-2202
> Project: Avro
> Issue Type: Bug
> Components: c++
> Affects Versions: 1.8.2
> Environment: OS: Gentoo Linux
> Compiler: Gcc 6.4.0 targeting musl libc 1.19 with stdlibc++ in a static build
> Reporter: Josh Scoggins
> Priority: Major
>
> Observed with master and version 1.8.2. Inside of the C++ implementation's
> CMakeLists.txt the lines 56-60 were added sometime in 2016 which activate
> features inside of libstdc++ to help find errors. This change has two side
> effects:
> # -g is eliminated from the build so debugging gdb becomes harder as source
> position data has been removed
> # The safety containers that implicitly wrap all standard containers somehow
> (I can't figure out exactly how) cause memory corruption when setMetadata is
> called (in version 1.8.2) or when a Writer object is destroyed (on master).
> Since our software uses musl libc with libstdc++ I believe that it is an
> interaction with these debugging features which cause memory corruption (as I
> said, I have no clue _why_ it is happening, only that these features _cause_
> it :()
> Previously, we were using 1.7.7 which did not have these lines in its
> CMakeLists.txt and thus did not exhibit any sort of memory corruption. I was
> able to work around this by removing lines 56-60 from CMakeLists.txt so our
> static libs could be built and our unit tests not crash by writing to memory
> it did not own. There should be a toggle or something similar to turn off
> these features for debug builds as they are for developers of avro only.
--
This message was sent by Atlassian JIRA
(v7.6.3#76005)