rocksdb icon indicating copy to clipboard operation
rocksdb copied to clipboard

rocksdb_close throwing error

Open narayana1923 opened this issue 11 months ago • 2 comments

Hi, I am using rocksdb 5.8 in postgres and as part of the drop extension command I try to close rocksdb and remove its directories. When I get to the rocksdb_close function call its throwing an error message in postgres logs saying "malloc(): unaligned tcache chunk detected" and crashing the server. Below is the GDB stack trace:

#5  0x00007fc987a896f6 in __libc_message (action=action@entry=do_abort, fmt=fmt@entry=0x7fc987bdbb8c "%s\n") at ../sysdeps/posix/libc_fatal.c:155
#6  0x00007fc987aa0d7c in malloc_printerr (str=str@entry=0x7fc987bde5d8 "malloc_consolidate(): unaligned fastbin chunk detected") at ./malloc/malloc.c:5664
#7  0x00007fc987aa1a0c in malloc_consolidate (av=av@entry=0x7fc987c19c80 <main_arena>) at ./malloc/malloc.c:4750
#8  0x00007fc987aa2f20 in _int_free (av=0x7fc987c19c80 <main_arena>, p=0x5640b28e95b0, have_lock=<optimized out>) at ./malloc/malloc.c:4674
#9  0x00007fc987aa54d3 in __GI___libc_free (mem=<optimized out>) at ./malloc/malloc.c:3391
#10 0x00007fc9844f767d in std::default_delete<char []>::operator() (this=<optimized out>, __ptr=<optimized out>) at /usr/include/c++/4.8.2/bits/unique_ptr.h:99
#11 std::unique_ptr<char [], std::default_delete<char []> >::~unique_ptr (this=0x5640b28cbcd0, __in_chrg=<optimized out>)    at /usr/include/c++/4.8.2/bits/unique_ptr.h:377
#12 rocksdb::AlignedBuffer::~AlignedBuffer (this=0x5640b28cbcc8, __in_chrg=<optimized out>) at ./util/aligned_buffer.h:29
#13 rocksdb::WritableFileWriter::~WritableFileWriter (this=0x5640b28cbcc0, __in_chrg=<optimized out>) at ./util/file_reader_writer.h:162
#14 std::default_delete<rocksdb::WritableFileWriter>::operator() (this=<optimized out>, __ptr=0x5640b28cbcc0) at /usr/include/c++/4.8.2/bits/unique_ptr.h:67
#15 std::unique_ptr<rocksdb::WritableFileWriter, std::default_delete<rocksdb::WritableFileWriter> >::~unique_ptr (this=0x5640b28c5200, __in_chrg=<optimized out>)    at /usr/include/c++/4.8.2/bits/unique_ptr.h:184
#16 rocksdb::log::Writer::~Writer (this=0x5640b28c5200, __in_chrg=<optimized out>) at db/log_writer.cc:34
#17 0x00007fc98449b411 in rocksdb::DBImpl::LogWriterNumber::ClearWriter (this=0x5640b28a3bd0) at ./db/db_impl.h:917
#18 rocksdb::DBImpl::~DBImpl (this=0x5640b28a2dc0, __in_chrg=<optimized out>) at db/db_impl.cc:324
#19 0x00007fc98449bb41 in rocksdb::DBImpl::~DBImpl (this=0x5640b28a2dc0, __in_chrg=<optimized out>) at db/db_impl.cc:357
#20 0x00007fc98443fafa in rocksdb_close (db=0x5640b28fb6c0) at db/c.cc:627

What am I missing here? Thanks in advance for any response

narayana1923 avatar Sep 07 '23 06:09 narayana1923

@narayana1923 It may not necessarily be a problem with the functions shown on the stack. Some memory corruption could have occurred earlier. Can you reproduce this with an asan build?

anand1976 avatar Sep 11 '23 22:09 anand1976

@anand1976 I tried compiling rocksdb with make shared_lib COMPILE_WITH_ASAN = 1 but couldn't find any memory corruption error in runtime

narayana1923 avatar Sep 12 '23 08:09 narayana1923