[Kea-users] Remote debugging in KEA

Tomek Mrugalski tomasz at isc.org
Fri Nov 2 16:08:34 UTC 2018


On 02/11/2018 15:50, Hreiðar Jóelsson wrote:
> thanks, I was not able to get gdb working remotely with Clion but I 
> managed to get some trace of the crash by running it locally on the 
> server. The problem is that I’m not sure what to make of it 😊
See some tips below.

> Thread 1 "kea-dhcp4" received signal SIGSEGV, Segmentation fault.
> 
> #0  0x00007ffe4c2338b8 in ?? ()
> 
> #1  0x00007f5f823fb960 in isc::dhcp::LibDHCP::packOptions4 (buf=..., 
> options=std::multimap with 8 elements = {...}) at libdhcp++.cc:805
This is the part of the code that's segfaulting:

    for (OptionCollection::const_iterator it = options.begin();
         it != options.end(); ++it) {

Line 805:            it->second->pack(buf);

This is a packOptions4 method that iterates over DHCP options stored in
Pkt4 packet. It is trying to pack (prepare on-wire representation of the
options). The option collection is a multimap that stores each option
as <unsigned int, OptionPtr>. The first entity is option code, and the
second is supposed to be a smart pointer to Option instance (or a class
derived from Option). It looks like one of the options is not
correctly added to the packet. Since this is the first time such a
problem is reported, I suspect is it your hook that adds the option
in some incorrect way. Can't say what's wrong for sure - perhaps you
added raw pointer, instead of OptionPtr (which is a shared pointer),
maybe it's null or the underlying object is misimplemented.

If I were you, I'd start with printing out it->first before calling.
Something like this added before line 805:

std::cout << "Packing option " << it->first << ", the pointer is " <<
it->second << std::endl;

At the very least, this will print out the code of the option that
causing the crash. Hopefully this will give you some pointers.
If it->second is not null, you may call it->second->toText(0) and print
out the result.

> I ‘we discovered that the server crashes when I feed in DHCP option 
> using isc::asiolink::IOAddress, where the type is ipv4-address, like 
> option 6 – domain-name-servers. Maybe someone can show an example of
> how one should go about overwriting those kinds of options.
And here's probably the reason. Please take a look at
src/lib/dhcp/tests. There are many examples there. A good file to look
at is option4_addrlist_unittest.cc

Finally, this kind of questions are better suited for kea-dev. Average
users are probably not interested in internal workings of kea.

Speaking of remote debugging, perhaps you want to set Kea running on
your local dev system? You can consider running perfdhcp to generate
client traffic. It's not perfect and has many shortcomings, but it may
be something to look at.

Hope that helps,
Tomek



More information about the Kea-users mailing list