You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@pulsar.apache.org by "BewareMyPower (via GitHub)" <gi...@apache.org> on 2023/05/23 08:39:51 UTC

[GitHub] [pulsar-client-python] BewareMyPower commented on issue #103: bad_weak_ptr will be thrown if client.close() is not called after ResultInterrupted is caught

BewareMyPower commented on issue #103:
URL: https://github.com/apache/pulsar-client-python/issues/103#issuecomment-1558814760

   ### Summary
   
   This issue is hard to avoid because it happens when the destructor of `ConsumerImpl` tries to create a `std::shared_ptr` from the `libpulsar.so`, while this library is already unloaded by the Python interpreter.
   
   ### Analysis
   
   We can see the crash happened in `ConsumerImpl::shutdown`:
   
   ```
   #10 std::shared_ptr<pulsar::ClientImpl>::~shared_ptr (this=<optimized out>, __in_chrg=<optimized out>) at /usr/include/c++/9/bits/shared_ptr.h:103
   #11 pulsar::ConsumerImpl::shutdown (this=<optimized out>) at /home/xyz/github.com/apache/pulsar-client-cpp/lib/ConsumerImpl.cc:1267
   #12 0x00007ffff7123a5e in pulsar::ConsumerImpl::~ConsumerImpl (this=0x7ffff0003250, __in_chrg=<optimized out>)
       at /home/xyz/github.com/apache/pulsar-client-cpp/lib/ConsumerImpl.cc:164
   ```
   
   https://github.com/apache/pulsar-client-cpp/blob/1dad87bb3b804d2aa8542ac48e4c35228ac2f1bf/lib/ConsumerImpl.cc#L1267
   
   ```c++
       auto client = client_.lock();
   ```
   
   Even if I commented the `client_.lock()` related code, it now happened when constructing a `Message` object in `shutdown`:
   
   ```
   #10 std::shared_ptr<pulsar::MessageImpl>::~shared_ptr (this=<optimized out>, __in_chrg=<optimized out>) at /usr/include/c++/9/bits/shared_ptr.h:103
   #11 pulsar::Message::~Message (this=<optimized out>, __in_chrg=<optimized out>) at /home/xyz/github.com/apache/pulsar-client-cpp/include/pulsar/Message.h:43
   #12 pulsar::ConsumerImpl::failPendingReceiveCallback (this=<optimized out>) at /home/xyz/github.com/apache/pulsar-client-cpp/lib/ConsumerImpl.cc:622
   #13 0x00007ffff7122cd0 in pulsar::ConsumerImpl::shutdown (this=0x7ffff0003250) at /home/xyz/github.com/apache/pulsar-client-cpp/lib/ConsumerImpl.cc:1274
   ```
   
   https://github.com/apache/pulsar-client-cpp/blob/1dad87bb3b804d2aa8542ac48e4c35228ac2f1bf/lib/ConsumerImpl.cc#L622
   
   ```c++
       Message msg;
   ```


-- 
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: commits-unsubscribe@pulsar.apache.org

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