You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@pulsar.apache.org by GitBox <gi...@apache.org> on 2020/06/21 11:51:37 UTC

[GitHub] [pulsar] firefeifei opened a new issue #7327: 2.6.0 cpp client crash

firefeifei opened a new issue #7327:
URL: https://github.com/apache/pulsar/issues/7327


   **Describe the bug**
   A clear and concise description of what the bug is.
   
   **To Reproduce*
   
   **Expected behavior**
   A clear and concise description of what you expected to happen.
   
   **Screenshots**
   
   call this api, cpp client crash 
   
   pulsar_client_create_producer(m_client, topic.c_str(), producer_conf, &producer)
   
   **Desktop (please complete the following information):**
    - OS:linux kernel  4.14.105
   
   **Additional context**
   
   
   (gdb) bt
   #0  0x00007f8307f4c377 in raise () from /lib64/libc.so.6
   #1  0x00007f8307f4da68 in abort () from /lib64/libc.so.6
   #2  0x0000000000c7c515 in __gnu_cxx::__verbose_terminate_handler () at ../../../../libstdc++-v3/libsupc++/vterminate.cc:95
   #3  0x0000000000c27896 in __cxxabiv1::__terminate (handler=<optimized out>) at ../../../../libstdc++-v3/libsupc++/eh_terminate.cc:38
   #4  0x0000000000c278c3 in std::terminate () at ../../../../libstdc++-v3/libsupc++/eh_terminate.cc:48
   #5  0x0000000000c6e775 in std::(anonymous namespace)::execute_native_thread_routine (__p=<optimized out>) at ../../../../../libstdc++-v3/src/c++11/thread.cc:92
   #6  0x00007f8308d00ea5 in start_thread () from /lib64/libpthread.so.0
   #7  0x00007f83080148cd in clone () from /lib64/libc.so.6


----------------------------------------------------------------
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:
users@infra.apache.org



[GitHub] [pulsar] firefeifei commented on issue #7327: 2.6.0 cpp client crash

Posted by GitBox <gi...@apache.org>.
firefeifei commented on issue #7327:
URL: https://github.com/apache/pulsar/issues/7327#issuecomment-650523096


   You can test this code without custom logger


----------------------------------------------------------------
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:
users@infra.apache.org



[GitHub] [pulsar] BewareMyPower commented on issue #7327: 2.6.0 cpp client crash

Posted by GitBox <gi...@apache.org>.
BewareMyPower commented on issue #7327:
URL: https://github.com/apache/pulsar/issues/7327#issuecomment-723089645


   I've reproduced it with boost 1.54.
   
   ```c++
   #include <string>
   #include <pulsar/c/client.h>
   
   int main(int argc, char* argv[]) {
       std::string service_url = "pulsar://localhost:65531";
       auto m_conf = pulsar_client_configuration_create();
       auto m_client = pulsar_client_create(service_url.c_str(), m_conf);
       auto producer_conf = pulsar_producer_configuration_create();
       pulsar_producer_t* producer = NULL;
       auto err = pulsar_client_create_producer(m_client, "my-topic", producer_conf, &producer);
       if (err != pulsar_result_Ok) {
           pulsar_producer_configuration_free(producer_conf);
           return 1;
       }
       return 0;
   }
   ```
   
   The output:
   
   ```
   2020-11-06 21:46:16.585 INFO  [140320113425088] ConnectionPool:85 | Created connection for pulsar://localhost:65531
   2020-11-06 21:46:16.589 INFO  [140320018294528] ClientConnection:235 | [<none> -> pulsar://localhost:65531] Destroyed connection
   terminate called after throwing an instance of 'boost::exception_detail::clone_impl<boost::exception_detail::error_info_injector<boost::system::system_error> >'
     what():  remote_endpoint: Transport endpoint is not connected
   Aborted (core dumped)
   ```
   
   Not sure whether it's the same issue. Or it's just because boost version is too low. I'll look into the issue later.


----------------------------------------------------------------
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:
users@infra.apache.org



[GitHub] [pulsar] firefeifei commented on issue #7327: 2.6.0 cpp client crash

Posted by GitBox <gi...@apache.org>.
firefeifei commented on issue #7327:
URL: https://github.com/apache/pulsar/issues/7327#issuecomment-647978089


   If I configure IP and Port, the Pulsar cluster does not start and crashes
   If the configured IP and Port pulsar services are normal, then there is no crash
   @sijie 


----------------------------------------------------------------
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:
users@infra.apache.org



[GitHub] [pulsar] firefeifei closed issue #7327: 2.6.0 cpp client crash

Posted by GitBox <gi...@apache.org>.
firefeifei closed issue #7327:
URL: https://github.com/apache/pulsar/issues/7327


   


----------------------------------------------------------------
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:
users@infra.apache.org



[GitHub] [pulsar] firefeifei edited a comment on issue #7327: 2.6.0 cpp client crash

Posted by GitBox <gi...@apache.org>.
firefeifei edited a comment on issue #7327:
URL: https://github.com/apache/pulsar/issues/7327#issuecomment-720332428






----------------------------------------------------------------
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:
users@infra.apache.org



[GitHub] [pulsar] firefeifei commented on issue #7327: 2.6.0 cpp client crash

Posted by GitBox <gi...@apache.org>.
firefeifei commented on issue #7327:
URL: https://github.com/apache/pulsar/issues/7327#issuecomment-720332428






----------------------------------------------------------------
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:
users@infra.apache.org



[GitHub] [pulsar] merlimat commented on issue #7327: 2.6.0 cpp client crash

Posted by GitBox <gi...@apache.org>.
merlimat commented on issue #7327:
URL: https://github.com/apache/pulsar/issues/7327#issuecomment-648499366


   @firefeifei Please provide a simple (complete) code example that reproduce the issue. That would make it far easier to understand what's happening. 


----------------------------------------------------------------
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:
users@infra.apache.org



[GitHub] [pulsar] sijie commented on issue #7327: 2.6.0 cpp client crash

Posted by GitBox <gi...@apache.org>.
sijie commented on issue #7327:
URL: https://github.com/apache/pulsar/issues/7327#issuecomment-647867239


   @firefeifei Can you share the code example so that we can reproduce?


----------------------------------------------------------------
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:
users@infra.apache.org



[GitHub] [pulsar] BewareMyPower commented on issue #7327: 2.6.0 cpp client crash

Posted by GitBox <gi...@apache.org>.
BewareMyPower commented on issue #7327:
URL: https://github.com/apache/pulsar/issues/7327#issuecomment-724420076


   After discussing with @firefeifei , the issue is with the link order of `libpulsar.a`. After putting `libpulsar.a` before other dependencies like boost, it works well.


----------------------------------------------------------------
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:
users@infra.apache.org



[GitHub] [pulsar] firefeifei commented on issue #7327: 2.6.0 cpp client crash

Posted by GitBox <gi...@apache.org>.
firefeifei commented on issue #7327:
URL: https://github.com/apache/pulsar/issues/7327#issuecomment-648631698


   
       m_conf = pulsar_client_configuration_create();
       pulsar_client_configuration_set_logger(m_conf, PulsarProducer::pulsar_logger, (void*)this);
       m_client = pulsar_client_create(service_url.c_str(), m_conf);
       pulsar_producer_configuration_t* producer_conf = pulsar_producer_configuration_create();
       pulsar_producer_configuration_set_batching_enabled(producer_conf, 0);
       pulsar_producer_configuration_set_max_pending_messages(producer_conf, 1000000);
       pulsar_result err = pulsar_client_create_producer(m_client, topic.c_str(), producer_conf, &producer);
        if (err != pulsar_result_Ok) {
           pulsar_producer_configuration_free(producer_conf);
          return NULL;
        }
   
   service_url: 127.0.0.1:5678
   
   


----------------------------------------------------------------
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:
users@infra.apache.org



[GitHub] [pulsar] merlimat commented on issue #7327: 2.6.0 cpp client crash

Posted by GitBox <gi...@apache.org>.
merlimat commented on issue #7327:
URL: https://github.com/apache/pulsar/issues/7327#issuecomment-648868097


   Have you tried removing the custom logger?


----------------------------------------------------------------
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:
users@infra.apache.org



[GitHub] [pulsar] BewareMyPower commented on issue #7327: 2.6.0 cpp client crash

Posted by GitBox <gi...@apache.org>.
BewareMyPower commented on issue #7327:
URL: https://github.com/apache/pulsar/issues/7327#issuecomment-653651172


   I cannot reproduce the problem, assuming your code is like:
   
   ```c++
   #include <iostream>
   #include <string>
   #include <pulsar/c/client.h>
   
   int main(int argc, char* argv[]) {
       if (argc < 2) {
           std::cerr << "Usage: " << argv[0] << " service-url" << std::endl;
           return 1;
       }
       std::string topic = "Foo";
       std::string service_url = argv[1];
       auto m_conf = pulsar_client_configuration_create();
       auto m_client = pulsar_client_create(service_url.c_str(), m_conf);
       auto producer_conf = pulsar_producer_configuration_create();
       pulsar_producer_configuration_set_batching_enabled(producer_conf, 0);
       pulsar_producer_configuration_set_max_pending_messages(producer_conf, 10000);
       pulsar_producer_t* producer = NULL;
       auto err = pulsar_client_create_producer(m_client, topic.c_str(), producer_conf, &producer);
       if (err != pulsar_result_Ok) {
           pulsar_producer_configuration_free(producer_conf);
           return 1;
       }
       return 0;
   }
   
   ```
   
   The running result:
   
   ```
   $ ./examples/SampleProducer pulsar://127.0.0.1:5678
   2020-07-04 02:32:31.475 INFO  [140369736358592] ConnectionPool:85 | Created connection for pulsar://127.0.0.1:5678
   2020-07-04 02:32:31.477 ERROR [140369636267776] ClientConnection:385 | [<none> -> pulsar://127.0.0.1:5678] Failed to establish connection: Connection refused
   2020-07-04 02:32:31.477 INFO  [140369636267776] ClientConnection:1372 | [<none> -> pulsar://127.0.0.1:5678] Connection closed
   2020-07-04 02:32:31.477 ERROR [140369636267776] ClientImpl:180 | Error Checking/Getting Partition Metadata while creating producer on persistent://public/default/Foo -- ConnectError
   2020-07-04 02:32:31.477 INFO  [140369636267776] ClientConnection:235 | [<none> -> pulsar://127.0.0.1:5678] Destroyed connection
   ```
   
   Could you provide your log? In addition, could you use a higher version GCC to debug? Your backtrace lost some debug info because of libstdc++'s BUG, see [How we discovered why C++ exceptions disappear in stack trace](https://le.qun.ch/en/blog/libstdc++-bug/)


----------------------------------------------------------------
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:
users@infra.apache.org



[GitHub] [pulsar] BewareMyPower commented on issue #7327: 2.6.0 cpp client crash

Posted by GitBox <gi...@apache.org>.
BewareMyPower commented on issue #7327:
URL: https://github.com/apache/pulsar/issues/7327#issuecomment-720360393


   From the stack we can see the segmentation fault was caused by `boost::asio::ip::tcp::socket`'s constructor. I found some similar issues:
   - https://stackoverflow.com/questions/45923885/boost-asio-io-service-multiple-objects-from-multiple-source-files-threads-cras
   - https://github.com/mostphotos/beanstalkpp/pull/6
   
   Could you give the version of boost dependencies by `ldd libpulsar.so`? 


----------------------------------------------------------------
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:
users@infra.apache.org



[GitHub] [pulsar] BewareMyPower commented on issue #7327: 2.6.0 cpp client crash

Posted by GitBox <gi...@apache.org>.
BewareMyPower commented on issue #7327:
URL: https://github.com/apache/pulsar/issues/7327#issuecomment-723920787


   Please try with following diff and take a look again
   
   ```diff
   diff --git a/pulsar-client-cpp/lib/ClientConnection.cc b/pulsar-client-cpp/lib/ClientConnection.cc
   index 22cc420..824d54a 100644
   --- a/pulsar-client-cpp/lib/ClientConnection.cc
   +++ b/pulsar-client-cpp/lib/ClientConnection.cc
   @@ -340,9 +340,15 @@ void ClientConnection::handleTcpConnected(const boost::system::error_code& err,
                                              tcp::resolver::iterator endpointIterator) {
        if (!err) {
            std::stringstream cnxStringStream;
   -        cnxStringStream << "[" << socket_->local_endpoint() << " -> " << socket_->remote_endpoint() << "] ";
   -        cnxString_ = cnxStringStream.str();
   -
   +        try {
   +            cnxStringStream << "[" << socket_->local_endpoint() << " -> " << socket_->remote_endpoint()
   +                            << "] ";
   +            cnxString_ = cnxStringStream.str();
   +        } catch (const boost::system::system_error& e) {
   +            LOG_ERROR("Failed to get endpoint: " << e.what());
   +            close();
   +            return;
   +        }
            if (logicalAddress_ == physicalAddress_) {
                LOG_INFO(cnxString_ << "Connected to broker");
            } else {
   ```


----------------------------------------------------------------
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:
users@infra.apache.org