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

Segmentation fault when creating producer #125

Closed
xhcqwlgithub opened this issue Jun 25, 2014 · 2 comments
Closed

Segmentation fault when creating producer #125

xhcqwlgithub opened this issue Jun 25, 2014 · 2 comments
Labels

Comments

@xhcqwlgithub
Copy link
Contributor

The code is as follows:

79 PropertyConfigurator::doConfigure(log_str);
80 RdKafka::Conf *gconf = RdKafka::Conf::create(RdKafka::Conf::CONF_GLOBAL);
81 RdKafka::Conf *tconf = RdKafka::Conf::create(RdKafka::Conf::CONF_TOPIC);
82
83 gconf->set("metadata.broker.list", "10.11.196.115:9092", errstr);
84 producer_ = RdKafka::Producer::create(gconf, errstr);

the information in the stack:

program received signal SIGSEGV, Segmentation fault.
[Switching to Thread 0x41401940 (LWP 18931)]
RdKafka::socket_cb_trampoline (domain=2, type=1, protocol=6, opaque=)
at thirdparty/librdkafka/src-cpp/HandleImpl.cpp:92
92 return handle->socket_cb_->socket_cb(domain, type, protocol);
(gdb) bt
#0 RdKafka::socket_cb_trampoline (domain=2, type=1, protocol=6, opaque=)

at thirdparty/librdkafka/src-cpp/HandleImpl.cpp:92

#1 0x00000000005a93e0 in rd_kafka_broker_connect (arg=)

at thirdparty/librdkafka/src/rdkafka_broker.c:1543

#2 rd_kafka_broker_thread_main (arg=)

at thirdparty/librdkafka/src/rdkafka_broker.c:3972

#3 0x000000366100673d in start_thread () from /lib64/libpthread.so.0
#4 0x00000036604d3f6d in clone () from /lib64/libc.so.6

And when I added a constructor to class ConfImpl, the error had not happen again.
the constructor code is as follows:

135 class ConfImpl : public Conf {
136 public:
137 ConfImpl()
138 :dr_cb_(NULL),
139 event_cb_(NULL),
140 socket_cb_(NULL),
141 open_cb_(NULL),
142 partitioner_cb_(NULL){}
143 ~ConfImpl () {
144 if (rk_conf_)
145 rd_kafka_conf_destroy(rk_conf_);
146 else
147 rd_kafka_topic_conf_destroy(rkt_conf_);
148 }
149

@xhcqwlgithub xhcqwlgithub changed the title Segmentation fault when create producer Segmentation fault when creating producer Jun 25, 2014
@edenhill
Copy link
Contributor

Sorry for not responding to this earlier, I lost it somehow.

Would you care to submit a pull request for your fix?

@edenhill
Copy link
Contributor

edenhill commented Aug 2, 2014

Fixed in master branch.
This also changes the Conf semantics:
the application may now reuse Conf objects after Topic/Producer/Consumer ::create calls and must delete the Conf objects itself.

@edenhill edenhill closed this as completed Aug 2, 2014
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants