[ 
https://issues.apache.org/jira/browse/ORC-1288?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17618678#comment-17618678
 ] 

noirello commented on ORC-1288:
-------------------------------

Backtrace:
{noformat}
Program received signal SIGSEGV, Segmentation fault.
orc::MemoryPoolImpl::free (this=0x5555559f6018 
<orc::getDefaultPool()::internal>, p=0x7ffff7756010 <error: Cannot access 
memory at address 0x7ffff7756010>)
    at /home/noirello/workspace/orc/c++/src/MemoryPool.cc:48
48        }
(gdb) bt
#0  orc::MemoryPoolImpl::free (this=0x5555559f6018 
<orc::getDefaultPool()::internal>, p=0x7ffff7756010 <error: Cannot access 
memory at address 0x7ffff7756010>)
    at /home/noirello/workspace/orc/c++/src/MemoryPool.cc:48
#1  0x000055555557d005 in orc::DataBuffer<char>::~DataBuffer 
(this=0x555555a16250, __in_chrg=<optimized out>) at 
/home/noirello/workspace/orc/c++/src/MemoryPool.cc:121
#2  0x000055555557d024 in orc::DataBuffer<char>::~DataBuffer 
(this=0x555555a16250, __in_chrg=<optimized out>) at 
/home/noirello/workspace/orc/c++/src/MemoryPool.cc:123
#3  0x000055555559680e in std::default_delete<orc::DataBuffer<char> 
>::operator() (this=0x555555a0c580, __ptr=0x555555a16250) at 
/usr/include/c++/9/bits/unique_ptr.h:81
#4  0x00005555555907e2 in std::unique_ptr<orc::DataBuffer<char>, 
std::default_delete<orc::DataBuffer<char> > >::~unique_ptr 
(this=0x555555a0c580, __in_chrg=<optimized out>)
    at /usr/include/c++/9/bits/unique_ptr.h:292
#5  0x00005555555de2ca in orc::BufferedOutputStream::~BufferedOutputStream 
(this=0x555555a0c570, __in_chrg=<optimized out>) at 
/home/noirello/workspace/orc/c++/src/io/OutputStream.cc:44
#6  0x000055555565fd02 in orc::CompressionStreamBase::~CompressionStreamBase 
(this=0x555555a0c570, __in_chrg=<optimized out>) at 
/home/noirello/workspace/orc/c++/src/Compression.cc:51
#7  0x000055555565fd5a in orc::CompressionStream::~CompressionStream 
(this=0x555555a0c570, __in_chrg=<optimized out>) at 
/home/noirello/workspace/orc/c++/src/Compression.cc:160
#8  0x000055555565fdbe in orc::ZlibCompressionStream::~ZlibCompressionStream 
(this=0x555555a0c570, __in_chrg=<optimized out>) at 
/home/noirello/workspace/orc/c++/src/Compression.cc:231
#9  0x000055555565fdde in orc::ZlibCompressionStream::~ZlibCompressionStream 
(this=0x555555a0c570, __in_chrg=<optimized out>) at 
/home/noirello/workspace/orc/c++/src/Compression.cc:233
#10 0x00005555555d9954 in 
std::default_delete<orc::BufferedOutputStream>::operator() 
(this=0x555555a0cea8, __ptr=0x555555a0c570) at 
/usr/include/c++/9/bits/unique_ptr.h:81
#11 0x00005555555d7e20 in std::unique_ptr<orc::BufferedOutputStream, 
std::default_delete<orc::BufferedOutputStream> >::~unique_ptr 
(this=0x555555a0cea8, __in_chrg=<optimized out>)
    at /usr/include/c++/9/bits/unique_ptr.h:292
#12 0x0000555555673f15 in orc::ByteRleEncoderImpl::~ByteRleEncoderImpl 
(this=0x555555a0cea0, __in_chrg=<optimized out>) at 
/home/noirello/workspace/orc/c++/src/ByteRLE.cc:94
#13 0x0000555555674770 in orc::BooleanRleEncoderImpl::~BooleanRleEncoderImpl 
(this=0x555555a0cea0, __in_chrg=<optimized out>) at 
/home/noirello/workspace/orc/c++/src/ByteRLE.cc:265
#14 0x0000555555674790 in orc::BooleanRleEncoderImpl::~BooleanRleEncoderImpl 
(this=0x555555a0cea0, __in_chrg=<optimized out>) at 
/home/noirello/workspace/orc/c++/src/ByteRLE.cc:267
#15 0x0000555555651aa0 in std::default_delete<orc::ByteRleEncoder>::operator() 
(this=0x555555a0c388, __ptr=0x555555a0cea0) at 
/usr/include/c++/9/bits/unique_ptr.h:81
#16 0x000055555564ff68 in std::unique_ptr<orc::ByteRleEncoder, 
std::default_delete<orc::ByteRleEncoder> >::~unique_ptr (this=0x555555a0c388, 
__in_chrg=<optimized out>)
    at /usr/include/c++/9/bits/unique_ptr.h:292
#17 0x0000555555641d2a in orc::ColumnWriter::~ColumnWriter 
(this=0x555555a0c380, __in_chrg=<optimized out>) at 
/home/noirello/workspace/orc/c++/src/ColumnWriter.cc:136
#18 0x000055555564f902 in orc::IntegerColumnWriter::~IntegerColumnWriter 
(this=0x555555a0c380, __in_chrg=<optimized out>) at 
/home/noirello/workspace/orc/c++/src/ColumnWriter.cc:459
#19 0x000055555564f922 in orc::IntegerColumnWriter::~IntegerColumnWriter 
(this=0x555555a0c380, __in_chrg=<optimized out>) at 
/home/noirello/workspace/orc/c++/src/ColumnWriter.cc:459
#20 0x00005555555da154 in std::default_delete<orc::ColumnWriter>::operator() 
(this=0x555555a0bdb0, __ptr=0x555555a0c380) at 
/usr/include/c++/9/bits/unique_ptr.h:81
#21 0x00005555555d8410 in std::unique_ptr<orc::ColumnWriter, 
std::default_delete<orc::ColumnWriter> >::~unique_ptr (this=0x555555a0bdb0, 
__in_chrg=<optimized out>)
    at /usr/include/c++/9/bits/unique_ptr.h:292
#22 0x00005555556583c5 in std::_Destroy<std::unique_ptr<orc::ColumnWriter, 
std::default_delete<orc::ColumnWriter> > > (__pointer=0x555555a0bdb0)
    at /usr/include/c++/9/bits/stl_construct.h:98
#23 0x0000555555656f31 in 
std::_Destroy_aux<false>::__destroy<std::unique_ptr<orc::ColumnWriter, 
std::default_delete<orc::ColumnWriter> >*> (__first=0x555555a0bdb0,
    __last=0x555555a0bdb8) at /usr/include/c++/9/bits/stl_construct.h:108
#24 0x0000555555654eda in std::_Destroy<std::unique_ptr<orc::ColumnWriter, 
std::default_delete<orc::ColumnWriter> >*> (__first=0x555555a0bdb0, 
__last=0x555555a0bdb8)
    at /usr/include/c++/9/bits/stl_construct.h:137
#25 0x00005555556529bb in std::_Destroy<std::unique_ptr<orc::ColumnWriter, 
std::default_delete<orc::ColumnWriter> >*, std::unique_ptr<orc::ColumnWriter, 
std::default_delete<orc::ColumnWriter> > > (__first=0x555555a0bdb0, 
__last=0x555555a0bdb8) at /usr/include/c++/9/bits/stl_construct.h:206
#26 0x0000555555650a3d in std::vector<std::unique_ptr<orc::ColumnWriter, 
std::default_delete<orc::ColumnWriter> >, 
std::allocator<std::unique_ptr<orc::ColumnWriter, 
std::default_delete<orc::ColumnWriter> > > >::~vector (this=0x555555a17db8, 
__in_chrg=<optimized out>) at /usr/include/c++/9/bits/stl_vector.h:677
#27 0x000055555565ab30 in orc::StructColumnWriter::~StructColumnWriter 
(this=0x555555a17d30, __in_chrg=<optimized out>) at 
/home/noirello/workspace/orc/c++/src/ColumnWriter.cc:278
#28 0x000055555565ab5c in orc::StructColumnWriter::~StructColumnWriter 
(this=0x555555a17d30, __in_chrg=<optimized out>) at 
/home/noirello/workspace/orc/c++/src/ColumnWriter.cc:278
#29 0x00005555555da154 in std::default_delete<orc::ColumnWriter>::operator() 
(this=0x555555a14df8, __ptr=0x555555a17d30) at 
/usr/include/c++/9/bits/unique_ptr.h:81
--Type <RET> for more, q to quit, c to continue without paging--
#30 0x00005555555d8410 in std::unique_ptr<orc::ColumnWriter, 
std::default_delete<orc::ColumnWriter> >::~unique_ptr (this=0x555555a14df8, 
__in_chrg=<optimized out>)
    at /usr/include/c++/9/bits/unique_ptr.h:292
#31 0x00005555555dce42 in orc::WriterImpl::~WriterImpl (this=0x555555a14df0, 
__in_chrg=<optimized out>) at /home/noirello/workspace/orc/c++/src/Writer.cc:274
#32 0x00005555555dce6e in orc::WriterImpl::~WriterImpl (this=0x555555a14df0, 
__in_chrg=<optimized out>) at /home/noirello/workspace/orc/c++/src/Writer.cc:274
#33 0x000055555557c83c in 
std::default_delete<orc::Writer>::operator()(orc::Writer*) const ()
#34 0x000055555557c58a in std::unique_ptr<orc::Writer, 
std::default_delete<orc::Writer> >::~unique_ptr() ()
#35 0x000055555557c297 in main () {noformat}
Compile command:
{noformat}
g++ -I./_CPack_Packages/Linux/TGZ/ORC-1.9.0-SNAPSHOT-Linux/include -L 
./_CPack_Packages/Linux/TGZ/ORC-1.9.0-SNAPSHOT-Linux/lib ../test-double-free.c 
-lorc -lprotobuf -lprotoc -llz4 -lzstd -lz -lsnappy -lpthread -o 
test-double-free.o{noformat}

> [C++] Invalid memory freeing with ZLIB compression
> --------------------------------------------------
>
>                 Key: ORC-1288
>                 URL: https://issues.apache.org/jira/browse/ORC-1288
>             Project: ORC
>          Issue Type: Bug
>    Affects Versions: 1.8.0
>            Reporter: noirello
>            Priority: Major
>
> The simple example code ends with a segfault/munmap_chunk(): invalid pointer:
> {code:cpp}
> #include "orc/Common.hh"
> #include "orc/OrcFile.hh"
> using namespace orc;
> int main(void) {
>     ORC_UNIQUE_PTR<OutputStream> outStream = writeLocalFile("test_file.orc");
>     ORC_UNIQUE_PTR<Type> schema(Type::buildTypeFromString("struct<c0:int>"));
>     WriterOptions options;
>     options.setCompression(orc::CompressionKind_ZLIB);
>     options.setStripeSize(4096);
>     options.setCompressionBlockSize(4096);
>     ORC_UNIQUE_PTR<Writer> writer = createWriter(*schema, outStream.get(), 
> options);
>     uint64_t batchSize = 65535, rowCount = 10000000;
>     ORC_UNIQUE_PTR<ColumnVectorBatch> batch = 
> writer->createRowBatch(batchSize);
>     StructVectorBatch *root = dynamic_cast<StructVectorBatch *>(batch.get());
>     LongVectorBatch *c0 = dynamic_cast<LongVectorBatch *>(root->fields[0]);
>     uint64_t rows = 0;
>     
>     for (uint64_t i = 0; i < rowCount; ++i) {
>         c0->data[rows] = i;
>         rows++;
>         if (rows == batchSize) {
>             root->numElements = rows;
>             c0->numElements = rows;
>             writer->add(*batch);
>             rows = 0;
>         }
>     }
>     if (rows != 0) {
>         root->numElements = rows;
>         c0->numElements = rows;
>         writer->add(*batch);
>         rows = 0;
>     }
>     writer->close();
>     return 0;
> }
> {code}
> The bug depends on the stripe size, compression size, and the record number 
> written to the file as well. I wasn't able to reproduce the error with other 
> compression strategies than ZLIB.
> It looks like to me that it's related to 
> [ORC-1130|https://issues.apache.org/jira/projects/ORC/issues/ORC-1130] 
> somehow, but I couldn't comprehend how. (Reverting that modification on the 
> main branch solved the issue).



--
This message was sent by Atlassian Jira
(v8.20.10#820010)

Reply via email to