Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

AddressSanitizer: alloc-dealloc-mismatch (operator new [] vs free) #251

Open
cxcorp opened this issue Jul 9, 2023 · 2 comments
Open

AddressSanitizer: alloc-dealloc-mismatch (operator new [] vs free) #251

cxcorp opened this issue Jul 9, 2023 · 2 comments

Comments

@cxcorp
Copy link

cxcorp commented Jul 9, 2023

When compiling native node dependencies with -fsanitize=address to enable AddressSanitizer, there appears to be warnings originating from lmdb-js.

For example, when using a project that uses parcel's watch mode:

$ CFLAGS="-g -fsanitize=address -fno-omit-frame-pointer" \
CXXFLAGS="-g -fsanitize=address -fno-omit-frame-pointer" \
LDFLAGS="-fsanitize=address" \
npm_config_build_from_source=true \
JOBS=8 \
yarn install

$ LD_PRELOAD="/usr/lib64/libasan.so.8.0.0" yarn frontend:dev:start

Server running at http://localhost:1234
=================================================================
==18439==ERROR: AddressSanitizer: alloc-dealloc-mismatch (operator new [] vs free) on 0x625009830100
    #0 0x7f34fb0d7fc8 in __interceptor_free.part.0 (/usr/lib64/libasan.so.8.0.0+0xd7fc8) (BuildId: dc689b05ca2577037af24700212bb5cce1f91c8a)
    #1 0x7f34eb06866f in WriteWorker::DoWrites(MDB_txn*, EnvWrap*, unsigned int*, WriteWorker*) ../src/writer.cpp:298
    #2 0x7f34eb0696b3 in WriteWorker::Write() ../src/writer.cpp:400
    #3 0x7f34eb069cb3 in do_write(napi_env__*, void*) ../src/writer.cpp:362
    #4 0xb41369 in node::ThreadPoolWork::ScheduleWork()::{lambda(uv_work_s*)#1}::_FUN(uv_work_s*) (/home/ffffffff/.local/share/fnm/node-versions/v18.16.1/installation/bin/node+0xb41369) (BuildId: 1321ccb78e09b8a2eb2c74099fc19bfb3caf2063)
    #5 0x1659c73 in worker ../deps/uv/src/threadpool.c:122
    #6 0x7f34faaae906 in start_thread (/lib64/libc.so.6+0x8c906) (BuildId: 245240a31888ad5c11bbc55b18e02d87388f59a9)
    #7 0x7f34fab3486f in __clone3 (/lib64/libc.so.6+0x11286f) (BuildId: 245240a31888ad5c11bbc55b18e02d87388f59a9)

0x625009830100 is located 0 bytes inside of 9593-byte region [0x625009830100,0x625009832679)
allocated by thread T10 here:
    #0 0x7f34fb0d9f98 in operator new[](unsigned long) (/usr/lib64/libasan.so.8.0.0+0xd9f98) (BuildId: dc689b05ca2577037af24700212bb5cce1f91c8a)
    #1 0x7f34eb0c6ac3 in Compression::compress(MDB_val*, void (*)(MDB_val&)) ../src/compression.cpp:124
    #2 0x7f34eb0c6ac3 in Compression::compressInstruction(EnvWrap*, double*) ../src/compression.cpp:97
    #3 0x7f34eb0a5e02 in Napi::AsyncWorker::OnExecute(Napi::Env) ../../node-addon-api/napi-inl.h:4895
    #4 0x7f34eb0a5e02 in Napi::AsyncWorker::OnAsyncWorkExecute(napi_env__*, void*) ../../node-addon-api/napi-inl.h:4881
    #5 0xb41369 in node::ThreadPoolWork::ScheduleWork()::{lambda(uv_work_s*)#1}::_FUN(uv_work_s*) (/home/ffffffff/.local/share/fnm/node-versions/v18.16.1/installation/bin/node+0xb41369) (BuildId: 1321ccb78e09b8a2eb2c74099fc19bfb3caf2063)
    #6 0x1659c73 in worker ../deps/uv/src/threadpool.c:122
    #7 0x7f34faaae906 in start_thread (/lib64/libc.so.6+0x8c906) (BuildId: 245240a31888ad5c11bbc55b18e02d87388f59a9)

Thread T8 created by T0 here:
    #0 0x7f34fb048966 in pthread_create (/usr/lib64/libasan.so.8.0.0+0x48966) (BuildId: dc689b05ca2577037af24700212bb5cce1f91c8a)
    #1 0x166d2bb in uv_thread_create_ex ../deps/uv/src/unix/thread.c:279
    #2 0x166d2bb in uv_thread_create ../deps/uv/src/unix/thread.c:233
    #3 0x165a04a in init_threads ../deps/uv/src/threadpool.c:230
    #4 0x165a04a in init_once ../deps/uv/src/threadpool.c:257
    #5 0x7f34faab3af2 in __pthread_once_slow (/lib64/libc.so.6+0x91af2) (BuildId: 245240a31888ad5c11bbc55b18e02d87388f59a9)
    #6 0x166d628 in uv_once ../deps/uv/src/unix/thread.c:440
    #7 0x165a229 in uv__work_submit ../deps/uv/src/threadpool.c:266
    #8 0x1665321 in uv_fs_stat ../deps/uv/src/unix/fs.c:2128
    #9 0xb90dd4 in node::fs::Stat(v8::FunctionCallbackInfo<v8::Value> const&) (/home/ffffffff/.local/share/fnm/node-versions/v18.16.1/installation/bin/node+0xb90dd4) (BuildId: 1321ccb78e09b8a2eb2c74099fc19bfb3caf2063)
    #10 0xdbaa7f in v8::internal::MaybeHandle<v8::internal::Object> v8::internal::(anonymous namespace)::HandleApiCallHelper<false>(v8::internal::Isolate*, v8::internal::Handle<v8::internal::HeapObject>, v8::internal::Handle<v8::internal::HeapObject>, v8::internal::Handle<v8::internal::FunctionTemplateInfo>, v8::internal::Handle<v8::internal::Object>, v8::internal::BuiltinArguments) (/home/ffffffff/.local/share/fnm/node-versions/v18.16.1/installation/bin/node+0xdbaa7f) (BuildId: 1321ccb78e09b8a2eb2c74099fc19bfb3caf2063)
    #11 0xdbbfbe in v8::internal::Builtin_HandleApiCall(int, unsigned long*, v8::internal::Isolate*) (/home/ffffffff/.local/share/fnm/node-versions/v18.16.1/installation/bin/node+0xdbbfbe) (BuildId: 1321ccb78e09b8a2eb2c74099fc19bfb3caf2063)
    #12 0x16fb7f8 in Builtins_CEntry_Return1_DontSaveFPRegs_ArgvOnStack_BuiltinExit (/home/ffffffff/.local/share/fnm/node-versions/v18.16.1/installation/bin/node+0x16fb7f8) (BuildId: 1321ccb78e09b8a2eb2c74099fc19bfb3caf2063)
    #13 0x167f74f in Builtins_InterpreterEntryTrampoline (/home/ffffffff/.local/share/fnm/node-versions/v18.16.1/installation/bin/node+0x167f74f) (BuildId: 1321ccb78e09b8a2eb2c74099fc19bfb3caf2063)
    #14 0x167f74f in Builtins_InterpreterEntryTrampoline (/home/ffffffff/.local/share/fnm/node-versions/v18.16.1/installation/bin/node+0x167f74f) (BuildId: 1321ccb78e09b8a2eb2c74099fc19bfb3caf2063)
    #15 0x167f74f in Builtins_InterpreterEntryTrampoline (/home/ffffffff/.local/share/fnm/node-versions/v18.16.1/installation/bin/node+0x167f74f) (BuildId: 1321ccb78e09b8a2eb2c74099fc19bfb3caf2063)
    #16 0x174a1cd in Builtins_PromiseConstructor (/home/ffffffff/.local/share/fnm/node-versions/v18.16.1/installation/bin/node+0x174a1cd) (BuildId: 1321ccb78e09b8a2eb2c74099fc19bfb3caf2063)
    #17 0x167d26b in Builtins_JSBuiltinsConstructStub (/home/ffffffff/.local/share/fnm/node-versions/v18.16.1/installation/bin/node+0x167d26b) (BuildId: 1321ccb78e09b8a2eb2c74099fc19bfb3caf2063)
    #18 0x179967e in Builtins_ConstructHandler (/home/ffffffff/.local/share/fnm/node-versions/v18.16.1/installation/bin/node+0x179967e) (BuildId: 1321ccb78e09b8a2eb2c74099fc19bfb3caf2063)
    #19 0x167f74f in Builtins_InterpreterEntryTrampoline (/home/ffffffff/.local/share/fnm/node-versions/v18.16.1/installation/bin/node+0x167f74f) (BuildId: 1321ccb78e09b8a2eb2c74099fc19bfb3caf2063)
    #20 0x167f74f in Builtins_InterpreterEntryTrampoline (/home/ffffffff/.local/share/fnm/node-versions/v18.16.1/installation/bin/node+0x167f74f) (BuildId: 1321ccb78e09b8a2eb2c74099fc19bfb3caf2063)
    #21 0x167f74f in Builtins_InterpreterEntryTrampoline (/home/ffffffff/.local/share/fnm/node-versions/v18.16.1/installation/bin/node+0x167f74f) (BuildId: 1321ccb78e09b8a2eb2c74099fc19bfb3caf2063)
    #22 0x16b343e in Builtins_AsyncFunctionAwaitResolveClosure (/home/ffffffff/.local/share/fnm/node-versions/v18.16.1/installation/bin/node+0x16b343e) (BuildId: 1321ccb78e09b8a2eb2c74099fc19bfb3caf2063)
    #23 0x174bcf0 in Builtins_PromiseFulfillReactionJob (/home/ffffffff/.local/share/fnm/node-versions/v18.16.1/installation/bin/node+0x174bcf0) (BuildId: 1321ccb78e09b8a2eb2c74099fc19bfb3caf2063)
    #24 0x16a4bba in Builtins_RunMicrotasks (/home/ffffffff/.local/share/fnm/node-versions/v18.16.1/installation/bin/node+0x16a4bba) (BuildId: 1321ccb78e09b8a2eb2c74099fc19bfb3caf2063)
    #25 0x167dc82 in Builtins_JSRunMicrotasksEntry (/home/ffffffff/.local/share/fnm/node-versions/v18.16.1/installation/bin/node+0x167dc82) (BuildId: 1321ccb78e09b8a2eb2c74099fc19bfb3caf2063)
    #26 0xe9d659 in v8::internal::(anonymous namespace)::Invoke(v8::internal::Isolate*, v8::internal::(anonymous namespace)::InvokeParams const&) (/home/ffffffff/.local/share/fnm/node-versions/v18.16.1/installation/bin/node+0xe9d659) (BuildId: 1321ccb78e09b8a2eb2c74099fc19bfb3caf2063)
    #27 0xe9e25f in v8::internal::(anonymous namespace)::InvokeWithTryCatch(v8::internal::Isolate*, v8::internal::(anonymous namespace)::InvokeParams const&) [clone .constprop.84] (/home/ffffffff/.local/share/fnm/node-versions/v18.16.1/installation/bin/node+0xe9e25f) (BuildId: 1321ccb78e09b8a2eb2c74099fc19bfb3caf2063)
    #28 0xe9e969 in v8::internal::Execution::TryRunMicrotasks(v8::internal::Isolate*, v8::internal::MicrotaskQueue*, v8::internal::MaybeHandle<v8::internal::Object>*) (/home/ffffffff/.local/share/fnm/node-versions/v18.16.1/installation/bin/node+0xe9e969) (BuildId: 1321ccb78e09b8a2eb2c74099fc19bfb3caf2063)
    #29 0xecbe69 in v8::internal::MicrotaskQueue::RunMicrotasks(v8::internal::Isolate*) [clone .part.50] (/home/ffffffff/.local/share/fnm/node-versions/v18.16.1/installation/bin/node+0xecbe69) (BuildId: 1321ccb78e09b8a2eb2c74099fc19bfb3caf2063)
    #30 0xecc241 in v8::internal::MicrotaskQueue::PerformCheckpoint(v8::Isolate*) (/home/ffffffff/.local/share/fnm/node-versions/v18.16.1/installation/bin/node+0xecc241) (BuildId: 1321ccb78e09b8a2eb2c74099fc19bfb3caf2063)
    #31 0xdbaa7f in v8::internal::MaybeHandle<v8::internal::Object> v8::internal::(anonymous namespace)::HandleApiCallHelper<false>(v8::internal::Isolate*, v8::internal::Handle<v8::internal::HeapObject>, v8::internal::Handle<v8::internal::HeapObject>, v8::internal::Handle<v8::internal::FunctionTemplateInfo>, v8::internal::Handle<v8::internal::Object>, v8::internal::BuiltinArguments) (/home/ffffffff/.local/share/fnm/node-versions/v18.16.1/installation/bin/node+0xdbaa7f) (BuildId: 1321ccb78e09b8a2eb2c74099fc19bfb3caf2063)
    #32 0xdbbfbe in v8::internal::Builtin_HandleApiCall(int, unsigned long*, v8::internal::Isolate*) (/home/ffffffff/.local/share/fnm/node-versions/v18.16.1/installation/bin/node+0xdbbfbe) (BuildId: 1321ccb78e09b8a2eb2c74099fc19bfb3caf2063)
    #33 0x16fb7f8 in Builtins_CEntry_Return1_DontSaveFPRegs_ArgvOnStack_BuiltinExit (/home/ffffffff/.local/share/fnm/node-versions/v18.16.1/installation/bin/node+0x16fb7f8) (BuildId: 1321ccb78e09b8a2eb2c74099fc19bfb3caf2063)
    #34 0x167f74f in Builtins_InterpreterEntryTrampoline (/home/ffffffff/.local/share/fnm/node-versions/v18.16.1/installation/bin/node+0x167f74f) (BuildId: 1321ccb78e09b8a2eb2c74099fc19bfb3caf2063)
    #35 0x167dd5b in Builtins_JSEntryTrampoline (/home/ffffffff/.local/share/fnm/node-versions/v18.16.1/installation/bin/node+0x167dd5b) (BuildId: 1321ccb78e09b8a2eb2c74099fc19bfb3caf2063)
    #36 0x167da82 in Builtins_JSEntry (/home/ffffffff/.local/share/fnm/node-versions/v18.16.1/installation/bin/node+0x167da82) (BuildId: 1321ccb78e09b8a2eb2c74099fc19bfb3caf2063)
    #37 0xe9d18d in v8::internal::(anonymous namespace)::Invoke(v8::internal::Isolate*, v8::internal::(anonymous namespace)::InvokeParams const&) (/home/ffffffff/.local/share/fnm/node-versions/v18.16.1/installation/bin/node+0xe9d18d) (BuildId: 1321ccb78e09b8a2eb2c74099fc19bfb3caf2063)
    #38 0xe9e37e in v8::internal::Execution::Call(v8::internal::Isolate*, v8::internal::Handle<v8::internal::Object>, v8::internal::Handle<v8::internal::Object>, int, v8::internal::Handle<v8::internal::Object>*) (/home/ffffffff/.local/share/fnm/node-versions/v18.16.1/installation/bin/node+0xe9e37e) (BuildId: 1321ccb78e09b8a2eb2c74099fc19bfb3caf2063)
    #39 0xd786e2 in v8::Function::Call(v8::Local<v8::Context>, v8::Local<v8::Value>, int, v8::Local<v8::Value>*) (/home/ffffffff/.local/share/fnm/node-versions/v18.16.1/installation/bin/node+0xd786e2) (BuildId: 1321ccb78e09b8a2eb2c74099fc19bfb3caf2063)
    #40 0xabcd85 in node::InternalCallbackScope::Close() (/home/ffffffff/.local/share/fnm/node-versions/v18.16.1/installation/bin/node+0xabcd85) (BuildId: 1321ccb78e09b8a2eb2c74099fc19bfb3caf2063)
    #41 0xabce00 in node::InternalCallbackScope::~InternalCallbackScope() (/home/ffffffff/.local/share/fnm/node-versions/v18.16.1/installation/bin/node+0xabce00) (BuildId: 1321ccb78e09b8a2eb2c74099fc19bfb3caf2063)
    #42 0xb35fb8 in node::StartExecution(node::Environment*, std::function<v8::MaybeLocal<v8::Value> (node::StartExecutionCallbackInfo const&)>) (/home/ffffffff/.local/share/fnm/node-versions/v18.16.1/installation/bin/node+0xb35fb8) (BuildId: 1321ccb78e09b8a2eb2c74099fc19bfb3caf2063)
    #43 0xac1316 in node::LoadEnvironment(node::Environment*, std::function<v8::MaybeLocal<v8::Value> (node::StartExecutionCallbackInfo const&)>) (/home/ffffffff/.local/share/fnm/node-versions/v18.16.1/installation/bin/node+0xac1316) (BuildId: 1321ccb78e09b8a2eb2c74099fc19bfb3caf2063)
    #44 0xbc113f in node::NodeMainInstance::Run() (/home/ffffffff/.local/share/fnm/node-versions/v18.16.1/installation/bin/node+0xbc113f) (BuildId: 1321ccb78e09b8a2eb2c74099fc19bfb3caf2063)
    #45 0xb35bc7 in node::LoadSnapshotDataAndRun(node::SnapshotData const**, node::InitializationResult const*) (/home/ffffffff/.local/share/fnm/node-versions/v18.16.1/installation/bin/node+0xb35bc7) (BuildId: 1321ccb78e09b8a2eb2c74099fc19bfb3caf2063)
    #46 0xb3976e in node::Start(int, char**) (/home/ffffffff/.local/share/fnm/node-versions/v18.16.1/installation/bin/node+0xb3976e) (BuildId: 1321ccb78e09b8a2eb2c74099fc19bfb3caf2063)
    #47 0x7f34faa49b49 in __libc_start_call_main (/lib64/libc.so.6+0x27b49) (BuildId: 245240a31888ad5c11bbc55b18e02d87388f59a9)
    #48 0x7f34faa49c0a in __libc_start_main_alias_2 (/lib64/libc.so.6+0x27c0a) (BuildId: 245240a31888ad5c11bbc55b18e02d87388f59a9)
    #49 0xabbded in _start (/home/ffffffff/.local/share/fnm/node-versions/v18.16.1/installation/bin/node+0xabbded) (BuildId: 1321ccb78e09b8a2eb2c74099fc19bfb3caf2063)

Thread T10 created by T0 here:
    #0 0x7f34fb048966 in pthread_create (/usr/lib64/libasan.so.8.0.0+0x48966) (BuildId: dc689b05ca2577037af24700212bb5cce1f91c8a)
    #1 0x166d2bb in uv_thread_create_ex ../deps/uv/src/unix/thread.c:279
    #2 0x166d2bb in uv_thread_create ../deps/uv/src/unix/thread.c:233
    #3 0x165a04a in init_threads ../deps/uv/src/threadpool.c:230
    #4 0x165a04a in init_once ../deps/uv/src/threadpool.c:257
    #5 0x7f34faab3af2 in __pthread_once_slow (/lib64/libc.so.6+0x91af2) (BuildId: 245240a31888ad5c11bbc55b18e02d87388f59a9)
    #6 0x166d628 in uv_once ../deps/uv/src/unix/thread.c:440
    #7 0x165a229 in uv__work_submit ../deps/uv/src/threadpool.c:266
    #8 0x1665321 in uv_fs_stat ../deps/uv/src/unix/fs.c:2128
    #9 0xb90dd4 in node::fs::Stat(v8::FunctionCallbackInfo<v8::Value> const&) (/home/ffffffff/.local/share/fnm/node-versions/v18.16.1/installation/bin/node+0xb90dd4) (BuildId: 1321ccb78e09b8a2eb2c74099fc19bfb3caf2063)
    #10 0xdbaa7f in v8::internal::MaybeHandle<v8::internal::Object> v8::internal::(anonymous namespace)::HandleApiCallHelper<false>(v8::internal::Isolate*, v8::internal::Handle<v8::internal::HeapObject>, v8::internal::Handle<v8::internal::HeapObject>, v8::internal::Handle<v8::internal::FunctionTemplateInfo>, v8::internal::Handle<v8::internal::Object>, v8::internal::BuiltinArguments) (/home/ffffffff/.local/share/fnm/node-versions/v18.16.1/installation/bin/node+0xdbaa7f) (BuildId: 1321ccb78e09b8a2eb2c74099fc19bfb3caf2063)
    #11 0xdbbfbe in v8::internal::Builtin_HandleApiCall(int, unsigned long*, v8::internal::Isolate*) (/home/ffffffff/.local/share/fnm/node-versions/v18.16.1/installation/bin/node+0xdbbfbe) (BuildId: 1321ccb78e09b8a2eb2c74099fc19bfb3caf2063)
    #12 0x16fb7f8 in Builtins_CEntry_Return1_DontSaveFPRegs_ArgvOnStack_BuiltinExit (/home/ffffffff/.local/share/fnm/node-versions/v18.16.1/installation/bin/node+0x16fb7f8) (BuildId: 1321ccb78e09b8a2eb2c74099fc19bfb3caf2063)
    #13 0x167f74f in Builtins_InterpreterEntryTrampoline (/home/ffffffff/.local/share/fnm/node-versions/v18.16.1/installation/bin/node+0x167f74f) (BuildId: 1321ccb78e09b8a2eb2c74099fc19bfb3caf2063)
    #14 0x167f74f in Builtins_InterpreterEntryTrampoline (/home/ffffffff/.local/share/fnm/node-versions/v18.16.1/installation/bin/node+0x167f74f) (BuildId: 1321ccb78e09b8a2eb2c74099fc19bfb3caf2063)
    #15 0x167f74f in Builtins_InterpreterEntryTrampoline (/home/ffffffff/.local/share/fnm/node-versions/v18.16.1/installation/bin/node+0x167f74f) (BuildId: 1321ccb78e09b8a2eb2c74099fc19bfb3caf2063)
    #16 0x174a1cd in Builtins_PromiseConstructor (/home/ffffffff/.local/share/fnm/node-versions/v18.16.1/installation/bin/node+0x174a1cd) (BuildId: 1321ccb78e09b8a2eb2c74099fc19bfb3caf2063)
    #17 0x167d26b in Builtins_JSBuiltinsConstructStub (/home/ffffffff/.local/share/fnm/node-versions/v18.16.1/installation/bin/node+0x167d26b) (BuildId: 1321ccb78e09b8a2eb2c74099fc19bfb3caf2063)
    #18 0x179967e in Builtins_ConstructHandler (/home/ffffffff/.local/share/fnm/node-versions/v18.16.1/installation/bin/node+0x179967e) (BuildId: 1321ccb78e09b8a2eb2c74099fc19bfb3caf2063)
    #19 0x167f74f in Builtins_InterpreterEntryTrampoline (/home/ffffffff/.local/share/fnm/node-versions/v18.16.1/installation/bin/node+0x167f74f) (BuildId: 1321ccb78e09b8a2eb2c74099fc19bfb3caf2063)
    #20 0x167f74f in Builtins_InterpreterEntryTrampoline (/home/ffffffff/.local/share/fnm/node-versions/v18.16.1/installation/bin/node+0x167f74f) (BuildId: 1321ccb78e09b8a2eb2c74099fc19bfb3caf2063)
    #21 0x167f74f in Builtins_InterpreterEntryTrampoline (/home/ffffffff/.local/share/fnm/node-versions/v18.16.1/installation/bin/node+0x167f74f) (BuildId: 1321ccb78e09b8a2eb2c74099fc19bfb3caf2063)
    #22 0x16b343e in Builtins_AsyncFunctionAwaitResolveClosure (/home/ffffffff/.local/share/fnm/node-versions/v18.16.1/installation/bin/node+0x16b343e) (BuildId: 1321ccb78e09b8a2eb2c74099fc19bfb3caf2063)
    #23 0x174bcf0 in Builtins_PromiseFulfillReactionJob (/home/ffffffff/.local/share/fnm/node-versions/v18.16.1/installation/bin/node+0x174bcf0) (BuildId: 1321ccb78e09b8a2eb2c74099fc19bfb3caf2063)
    #24 0x16a4bba in Builtins_RunMicrotasks (/home/ffffffff/.local/share/fnm/node-versions/v18.16.1/installation/bin/node+0x16a4bba) (BuildId: 1321ccb78e09b8a2eb2c74099fc19bfb3caf2063)
    #25 0x167dc82 in Builtins_JSRunMicrotasksEntry (/home/ffffffff/.local/share/fnm/node-versions/v18.16.1/installation/bin/node+0x167dc82) (BuildId: 1321ccb78e09b8a2eb2c74099fc19bfb3caf2063)
    #26 0xe9d659 in v8::internal::(anonymous namespace)::Invoke(v8::internal::Isolate*, v8::internal::(anonymous namespace)::InvokeParams const&) (/home/ffffffff/.local/share/fnm/node-versions/v18.16.1/installation/bin/node+0xe9d659) (BuildId: 1321ccb78e09b8a2eb2c74099fc19bfb3caf2063)
    #27 0xe9e25f in v8::internal::(anonymous namespace)::InvokeWithTryCatch(v8::internal::Isolate*, v8::internal::(anonymous namespace)::InvokeParams const&) [clone .constprop.84] (/home/ffffffff/.local/share/fnm/node-versions/v18.16.1/installation/bin/node+0xe9e25f) (BuildId: 1321ccb78e09b8a2eb2c74099fc19bfb3caf2063)
    #28 0xe9e969 in v8::internal::Execution::TryRunMicrotasks(v8::internal::Isolate*, v8::internal::MicrotaskQueue*, v8::internal::MaybeHandle<v8::internal::Object>*) (/home/ffffffff/.local/share/fnm/node-versions/v18.16.1/installation/bin/node+0xe9e969) (BuildId: 1321ccb78e09b8a2eb2c74099fc19bfb3caf2063)
    #29 0xecbe69 in v8::internal::MicrotaskQueue::RunMicrotasks(v8::internal::Isolate*) [clone .part.50] (/home/ffffffff/.local/share/fnm/node-versions/v18.16.1/installation/bin/node+0xecbe69) (BuildId: 1321ccb78e09b8a2eb2c74099fc19bfb3caf2063)
    #30 0xecc241 in v8::internal::MicrotaskQueue::PerformCheckpoint(v8::Isolate*) (/home/ffffffff/.local/share/fnm/node-versions/v18.16.1/installation/bin/node+0xecc241) (BuildId: 1321ccb78e09b8a2eb2c74099fc19bfb3caf2063)
    #31 0xdbaa7f in v8::internal::MaybeHandle<v8::internal::Object> v8::internal::(anonymous namespace)::HandleApiCallHelper<false>(v8::internal::Isolate*, v8::internal::Handle<v8::internal::HeapObject>, v8::internal::Handle<v8::internal::HeapObject>, v8::internal::Handle<v8::internal::FunctionTemplateInfo>, v8::internal::Handle<v8::internal::Object>, v8::internal::BuiltinArguments) (/home/ffffffff/.local/share/fnm/node-versions/v18.16.1/installation/bin/node+0xdbaa7f) (BuildId: 1321ccb78e09b8a2eb2c74099fc19bfb3caf2063)
    #32 0xdbbfbe in v8::internal::Builtin_HandleApiCall(int, unsigned long*, v8::internal::Isolate*) (/home/ffffffff/.local/share/fnm/node-versions/v18.16.1/installation/bin/node+0xdbbfbe) (BuildId: 1321ccb78e09b8a2eb2c74099fc19bfb3caf2063)
    #33 0x16fb7f8 in Builtins_CEntry_Return1_DontSaveFPRegs_ArgvOnStack_BuiltinExit (/home/ffffffff/.local/share/fnm/node-versions/v18.16.1/installation/bin/node+0x16fb7f8) (BuildId: 1321ccb78e09b8a2eb2c74099fc19bfb3caf2063)
    #34 0x167f74f in Builtins_InterpreterEntryTrampoline (/home/ffffffff/.local/share/fnm/node-versions/v18.16.1/installation/bin/node+0x167f74f) (BuildId: 1321ccb78e09b8a2eb2c74099fc19bfb3caf2063)
    #35 0x167dd5b in Builtins_JSEntryTrampoline (/home/ffffffff/.local/share/fnm/node-versions/v18.16.1/installation/bin/node+0x167dd5b) (BuildId: 1321ccb78e09b8a2eb2c74099fc19bfb3caf2063)
    #36 0x167da82 in Builtins_JSEntry (/home/ffffffff/.local/share/fnm/node-versions/v18.16.1/installation/bin/node+0x167da82) (BuildId: 1321ccb78e09b8a2eb2c74099fc19bfb3caf2063)
    #37 0xe9d18d in v8::internal::(anonymous namespace)::Invoke(v8::internal::Isolate*, v8::internal::(anonymous namespace)::InvokeParams const&) (/home/ffffffff/.local/share/fnm/node-versions/v18.16.1/installation/bin/node+0xe9d18d) (BuildId: 1321ccb78e09b8a2eb2c74099fc19bfb3caf2063)
    #38 0xe9e37e in v8::internal::Execution::Call(v8::internal::Isolate*, v8::internal::Handle<v8::internal::Object>, v8::internal::Handle<v8::internal::Object>, int, v8::internal::Handle<v8::internal::Object>*) (/home/ffffffff/.local/share/fnm/node-versions/v18.16.1/installation/bin/node+0xe9e37e) (BuildId: 1321ccb78e09b8a2eb2c74099fc19bfb3caf2063)
    #39 0xd786e2 in v8::Function::Call(v8::Local<v8::Context>, v8::Local<v8::Value>, int, v8::Local<v8::Value>*) (/home/ffffffff/.local/share/fnm/node-versions/v18.16.1/installation/bin/node+0xd786e2) (BuildId: 1321ccb78e09b8a2eb2c74099fc19bfb3caf2063)
    #40 0xabcd85 in node::InternalCallbackScope::Close() (/home/ffffffff/.local/share/fnm/node-versions/v18.16.1/installation/bin/node+0xabcd85) (BuildId: 1321ccb78e09b8a2eb2c74099fc19bfb3caf2063)
    #41 0xabce00 in node::InternalCallbackScope::~InternalCallbackScope() (/home/ffffffff/.local/share/fnm/node-versions/v18.16.1/installation/bin/node+0xabce00) (BuildId: 1321ccb78e09b8a2eb2c74099fc19bfb3caf2063)
    #42 0xb35fb8 in node::StartExecution(node::Environment*, std::function<v8::MaybeLocal<v8::Value> (node::StartExecutionCallbackInfo const&)>) (/home/ffffffff/.local/share/fnm/node-versions/v18.16.1/installation/bin/node+0xb35fb8) (BuildId: 1321ccb78e09b8a2eb2c74099fc19bfb3caf2063)
    #43 0xac1316 in node::LoadEnvironment(node::Environment*, std::function<v8::MaybeLocal<v8::Value> (node::StartExecutionCallbackInfo const&)>) (/home/ffffffff/.local/share/fnm/node-versions/v18.16.1/installation/bin/node+0xac1316) (BuildId: 1321ccb78e09b8a2eb2c74099fc19bfb3caf2063)
    #44 0xbc113f in node::NodeMainInstance::Run() (/home/ffffffff/.local/share/fnm/node-versions/v18.16.1/installation/bin/node+0xbc113f) (BuildId: 1321ccb78e09b8a2eb2c74099fc19bfb3caf2063)
    #45 0xb35bc7 in node::LoadSnapshotDataAndRun(node::SnapshotData const**, node::InitializationResult const*) (/home/ffffffff/.local/share/fnm/node-versions/v18.16.1/installation/bin/node+0xb35bc7) (BuildId: 1321ccb78e09b8a2eb2c74099fc19bfb3caf2063)
    #46 0xb3976e in node::Start(int, char**) (/home/ffffffff/.local/share/fnm/node-versions/v18.16.1/installation/bin/node+0xb3976e) (BuildId: 1321ccb78e09b8a2eb2c74099fc19bfb3caf2063)
    #47 0x7f34faa49b49 in __libc_start_call_main (/lib64/libc.so.6+0x27b49) (BuildId: 245240a31888ad5c11bbc55b18e02d87388f59a9)
    #48 0x7f34faa49c0a in __libc_start_main_alias_2 (/lib64/libc.so.6+0x27c0a) (BuildId: 245240a31888ad5c11bbc55b18e02d87388f59a9)
    #49 0xabbded in _start (/home/ffffffff/.local/share/fnm/node-versions/v18.16.1/installation/bin/node+0xabbded) (BuildId: 1321ccb78e09b8a2eb2c74099fc19bfb3caf2063)

SUMMARY: AddressSanitizer: alloc-dealloc-mismatch (/usr/lib64/libasan.so.8.0.0+0xd7fc8) (BuildId: dc689b05ca2577037af24700212bb5cce1f91c8a) in __interceptor_free.part.0
==18439==HINT: if you don't care about these errors you may set ASAN_OPTIONS=alloc_dealloc_mismatch=0
==18439==ABORTING

The trace suggests that when creating compressed values, operator new[] is used:

lmdb-js/src/compression.cpp

Lines 123 to 125 in 6e4146d

int maxCompressedSize = LZ4_COMPRESSBOUND(dataLength);
char* compressed = new char[maxCompressedSize + prefixSize];
//fprintf(stdout, "compressing %u\n", dataLength);

but when freeing it, free is used

lmdb-js/src/writer.cpp

Lines 297 to 299 in 6e4146d

if (flags & COMPRESSIBLE)
free(value.mv_data);
break;

In this context, I would assume that there is no immediate problem as it's just an array, but with a more complex type this would result in the destructor not being ran.

Is this undefined behavior which should be fixed, or just something for me to ignore in the results?

kriszyp added a commit that referenced this issue Jul 11, 2023
@kriszyp
Copy link
Owner

kriszyp commented Jul 28, 2023

FYI, this should have been addressed in 2.8.3.

@cxcorp
Copy link
Author

cxcorp commented Jul 28, 2023

Great! Thanks for the heads-up. By the way, should it be delete[] as it's allocated with new []? I'm not too brushed up with C++.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants