-
Notifications
You must be signed in to change notification settings - Fork 3.6k
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
2.6.0 cpp client crash #7327
Comments
@firefeifei Can you share the code example so that we can reproduce? |
If I configure IP and Port, the Pulsar cluster does not start and crashes |
@firefeifei Please provide a simple (complete) code example that reproduce the issue. That would make it far easier to understand what's happening. |
service_url: 127.0.0.1:5678 |
Have you tried removing the custom logger? |
You can test this code without custom logger |
I cannot reproduce the problem, assuming your code is like: #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:
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 |
|
Hello,@sijie |
From the stack we can see the segmentation fault was caused by
Could you give the version of boost dependencies by |
1.54.0 |
I've reproduced it with boost 1.54. #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:
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. |
Please try with following diff and take a look again 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 { |
After discussing with @firefeifei , the issue is with the link order of |
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):
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=) 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=) 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
The text was updated successfully, but these errors were encountered: