bkietz commented on PR #571: URL: https://github.com/apache/arrow-nanoarrow/pull/571#issuecomment-2274377726
[Valgrind](https://github.com/apache/arrow-nanoarrow/actions/runs/10291048514/job/28482448351?pr=571#step:11:1049) is complaining about an invalid read. I can reproduce this locally and I get ``` ==308668== Invalid read of size 4 ==308668== at 0x13B378: flatcc_builder_create_cached_vtable (builder.c:1233) ==308668== by 0x13B882: flatcc_builder_end_table (builder.c:1353) ==308668== by 0x1342F6: org_apache_arrow_flatbuf_Message_end (flatcc_generated.h:9224) ==308668== by 0x1342F6: org_apache_arrow_flatbuf_Message_end_as_root (flatcc_generated.h:9244) ==308668== by 0x1342F6: ArrowIpcEncoderEncodeRecordBatch (encoder.c:583) ==308668== by 0x1342F6: ArrowIpcEncoderEncodeSimpleRecordBatch (encoder.c:599) ==308668== by 0x12BF27: ArrowIpcWriterWriteArrayView (writer.c:271) ==308668== by 0x127C4F: WriteNanoarrowStream (files_test.cc:216) ==308668== by 0x127C4F: TestFile::TestEqualsArrowCpp(std::__cxx11::basic_string<char, std::char_traits<char>, s td::allocator<char> > const&) (files_test.cc:247) ==308668== by 0x128623: TestFileFixture_NanoarrowIpcTestFileNativeEndian_Test::TestBody() (files_test.cc:391) ==308668== by 0x18A7C6: HandleSehExceptionsInMethodIfSupported<testing::Test, void> (gtest.cc:2612) ==308668== by 0x18A7C6: void testing::internal::HandleExceptionsInMethodIfSupported<testing::Test, void>(testin g::Test*, void (testing::Test::*)(), char const*) (gtest.cc:2648) ==308668== by 0x18AA20: Run (gtest.cc:2687) ==308668== by 0x18AA20: testing::Test::Run() (gtest.cc:2677) ==308668== by 0x18ADAE: testing::TestInfo::Run() (gtest.cc:2836) ==308668== by 0x18E21E: Run (gtest.cc:3015) ==308668== by 0x18E21E: testing::TestSuite::Run() (gtest.cc:2968) ==308668== by 0x193E52: testing::internal::UnitTestImpl::RunAllTests() (gtest.cc:5920) ==308668== by 0x18B056: HandleSehExceptionsInMethodIfSupported<testing::internal::UnitTestImpl, bool> (gtest.cc :2612) ==308668== by 0x18B056: bool testing::internal::HandleExceptionsInMethodIfSupported<testing::internal::UnitTest Impl, bool>(testing::internal::UnitTestImpl*, bool (testing::internal::UnitTestImpl::*)(), char const*) (gtest.cc: 2648) ==308668== Address 0x88fa018 is 40 bytes inside a block of size 128 free'd ==308668== at 0x484DCD3: realloc (in /usr/libexec/valgrind/vgpreload_memcheck-amd64-linux.so) ==308668== by 0x139FC8: flatcc_builder_default_alloc (builder.c:171) ==308668== by 0x13B312: reserve_buffer (builder.c:320) ==308668== by 0x13B312: flatcc_builder_create_cached_vtable (builder.c:1216) ==308668== by 0x13B882: flatcc_builder_end_table (builder.c:1353) ==308668== by 0x1342F6: org_apache_arrow_flatbuf_Message_end (flatcc_generated.h:9224) ==308668== by 0x1342F6: org_apache_arrow_flatbuf_Message_end_as_root (flatcc_generated.h:9244) ==308668== by 0x1342F6: ArrowIpcEncoderEncodeRecordBatch (encoder.c:583) ==308668== by 0x1342F6: ArrowIpcEncoderEncodeSimpleRecordBatch (encoder.c:599) ==308668== by 0x12BF27: ArrowIpcWriterWriteArrayView (writer.c:271) ==308668== by 0x127C4F: WriteNanoarrowStream (files_test.cc:216) ==308668== by 0x127C4F: TestFile::TestEqualsArrowCpp(std::__cxx11::basic_string<char, std::char_traits<char>, s td::allocator<char> > const&) (files_test.cc:247) ==308668== by 0x128623: TestFileFixture_NanoarrowIpcTestFileNativeEndian_Test::TestBody() (files_test.cc:391) ==308668== by 0x18A7C6: HandleSehExceptionsInMethodIfSupported<testing::Test, void> (gtest.cc:2612) ==308668== by 0x18A7C6: void testing::internal::HandleExceptionsInMethodIfSupported<testing::Test, void>(testin g::Test*, void (testing::Test::*)(), char const*) (gtest.cc:2648) ==308668== by 0x18AA20: Run (gtest.cc:2687) ==308668== by 0x18AA20: testing::Test::Run() (gtest.cc:2677) ==308668== by 0x18ADAE: testing::TestInfo::Run() (gtest.cc:2836) ==308668== by 0x18E21E: Run (gtest.cc:3015) ==308668== by 0x18E21E: testing::TestSuite::Run() (gtest.cc:2968) ==308668== Block was alloc'd at ==308668== at 0x484DCD3: realloc (in /usr/libexec/valgrind/vgpreload_memcheck-amd64-linux.so) ==308668== by 0x139FC8: flatcc_builder_default_alloc (builder.c:171) ==308668== by 0x13B312: reserve_buffer (builder.c:320) ==308668== by 0x13B312: flatcc_builder_create_cached_vtable (builder.c:1216) ==308668== by 0x13B882: flatcc_builder_end_table (builder.c:1353) ==308668== by 0x133DB1: org_apache_arrow_flatbuf_Message_end (flatcc_generated.h:9224) ==308668== by 0x133DB1: org_apache_arrow_flatbuf_Message_end_as_root (flatcc_generated.h:9244) ==308668== by 0x133DB1: ArrowIpcEncoderEncodeSchema (encoder.c:442) ==308668== by 0x12BDA7: ArrowIpcWriterWriteSchema (writer.c:245) ==308668== by 0x127C1B: WriteNanoarrowStream (files_test.cc:211) ==308668== by 0x127C1B: TestFile::TestEqualsArrowCpp(std::__cxx11::basic_string<char, std::char_traits<char>, s td::allocator<char> > const&) (files_test.cc:247) ==308668== by 0x128623: TestFileFixture_NanoarrowIpcTestFileNativeEndian_Test::TestBody() (files_test.cc:391) ==308668== by 0x18A7C6: HandleSehExceptionsInMethodIfSupported<testing::Test, void> (gtest.cc:2612) ==308668== by 0x18A7C6: void testing::internal::HandleExceptionsInMethodIfSupported<testing::Test, void>(testin g::Test*, void (testing::Test::*)(), char const*) (gtest.cc:2648) ==308668== by 0x18AA20: Run (gtest.cc:2687) ==308668== by 0x18AA20: testing::Test::Run() (gtest.cc:2677) ==308668== by 0x18ADAE: testing::TestInfo::Run() (gtest.cc:2836) ==308668== by 0x18E21E: Run (gtest.cc:3015) ==308668== by 0x18E21E: testing::TestSuite::Run() (gtest.cc:2968) ==308668== ``` AFAICT from preliminary debugging flatcc's usage of realloc() is not incorrect, and Valgrind doesn't complain about the same test compiled using clang. ASAN also doesn't produce any error here. In particular I don't get any segfaults (or Valgrind failures) when replacing realloc with an equivalent malloc+free. Maybe this should just be handled by a new suppression? ``` { <flatcc>:flatcc uses realloc() and valgrind thinks something was free'd Memcheck:Addr4 fun:flatcc_builder_create_cached_vtable } ``` -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected]
