equanz opened a new pull request #160:
URL: https://github.com/apache/pulsar-client-node/pull/160


   ### Motivation
   `MessageId::Serialize` possibly has a memory leak bug. Here are a simple 
reproduce code and valgrind log.
   
   ```js
   for (let i = 0; i < 1000; i += 1) {
     const msg = await consumer.receive();
   
     // serialize
     const serialize = msg.getMessageId().serialize();
     console.log(serialize);
   
     consumer.acknowledge(msg);
   }
   ```
   
   ```
   ==1048== 7,000 bytes in 1,000 blocks are definitely lost in loss record 67 
of 68
   ==1048==    at 0x50F4F73: malloc (vg_replace_malloc.c:309)
   ==1048==    by 0xA36C67A: pulsar_message_id_serialize (in 
/usr/lib/libpulsar.so.2.7.2)
   ==1048==    by 0x9F3E599: MessageId::Serialize(Napi::CallbackInfo const&) 
(in /app/node_modules/pulsar-client/build/Release/Pulsar.node)
   ==1048==    by 0x9F458D0: 
Napi::InstanceWrap<MessageId>::InstanceMethodCallbackWrapper(napi_env__*, 
napi_callback_info__*) (in 
/app/node_modules/pulsar-client/build/Release/Pulsar.node)
   ==1048==    by 0x9D7E5E: v8impl::(anonymous 
namespace)::FunctionCallbackWrapper::Invoke(v8::FunctionCallbackInfo<v8::Value> 
const&) (in /usr/bin/node)
   ==1048==    by 0xC03D0A: 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) (in 
/usr/bin/node)
   ==1048==    by 0xC052B5: 
v8::internal::Builtin_Impl_HandleApiCall(v8::internal::BuiltinArguments, 
v8::internal::Isolate*) (in /usr/bin/node)
   ==1048==    by 0xC05935: v8::internal::Builtin_HandleApiCall(int, unsigned 
long*, v8::internal::Isolate*) (in /usr/bin/node)
   ==1048==    by 0x1423358: 
Builtins_CEntry_Return1_DontSaveFPRegs_ArgvOnStack_BuiltinExit (in 
/usr/bin/node)
   ==1048==    by 0x13BC121: Builtins_InterpreterEntryTrampoline (in 
/usr/bin/node)
   ==1048==    by 0x13E8CEF: Builtins_AsyncFunctionAwaitResolveClosure (in 
/usr/bin/node)
   ==1048==    by 0x1464FED: Builtins_PromiseFulfillReactionJob (in 
/usr/bin/node)
   ```
   
   ### Modification
   * Free char pointer at Buffer finalization callback
   


-- 
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.

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


Reply via email to