<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<style type="text/css" style="display:none;"><!-- P {margin-top:0;margin-bottom:0;} --></style>
</head>
<body dir="ltr">
<div id="divtagdefaultwrapper" style="font-size:12pt;color:#000000;font-family:Calibri,Helvetica,sans-serif;" dir="ltr">
<p style="margin-top:0;margin-bottom:0">I understand that the problem is in my code.  I just thought I should tell someone in case they cared
<span>😊</span></p>
<p style="margin-top:0;margin-bottom:0"><span><br>
</span></p>
<p style="margin-top:0;margin-bottom:0"><span>If the Option used a visited_ flag then recursive calls could detect cycles established by callouts and throw an exception rather than crash.</span></p>
<p style="margin-top:0;margin-bottom:0"><br>
</p>
<p style="margin-top:0;margin-bottom:0"><span></span></p>
</div>
<hr style="display:inline-block;width:98%" tabindex="-1">
<div id="divRplyFwdMsg" dir="ltr"><font face="Calibri, sans-serif" style="font-size:11pt" color="#000000"><b>From:</b> Francis Dupont <fdupont@isc.org><br>
<b>Sent:</b> Monday, 5 February 2018 9:34:59 PM<br>
<b>To:</b> Dave Cole<br>
<b>Cc:</b> kea-dev@lists.isc.org<br>
<b>Subject:</b> Re: [kea-dev] Accidentally found infinite recursion in Kea 1.3 Option...</font>
<div> </div>
</div>
<div class="BodyFragment"><font size="2"><span style="font-size:11pt;">
<div class="PlainText">Dave Cole writes:<br>
> While adding more tests for my code I stumbled on a problem in Kea.  It is a <br>
> small thing in the scheme of things, but it might be of interest.<br>
<br>
=> IMHO the problem is in your code and is not prevented by Kea.<br>
<br>
> >>> from kea import *<br>
> >>> p = Pkt4(DHCPDISCOVER, 0)<br>
> >>> o = Option(1)<br>
> >>> o.addOption(o)<br>
> >>> p.addOption(o)<br>
> >>> p.pack()<br>
<br>
=> if I understand well you created a loop with an option including<br>
itself as a sub-option.<br>
<br>
> Program received signal SIGSEGV, Segmentation fault.<br>
<br>
=> even if the method is tail recursive its call consumes some stack<br>
until the stack underflows...<br>
<br>
> isc::dhcp::Option::len (this=0x555555ba3140) at option.cc:176<br>
> 176       size_t length = getHeaderLen() + data_.size();<br>
<br>
=> for documentation what is the source of the problem is:<br>
<br>
    // ... and sum of lengths of all suboptions<br>
    for (OptionCollection::const_iterator it = options_.begin();<br>
         it != options_.end();<br>
         ++it) {<br>
         length += (*it).second->len();<br>
                                 ^^^ recursive call<br>
    }<br>
                                      <br>
Thanks<br>
<br>
Francis Dupont <fdupont@isc.org><br>
</div>
</span></font></div>
</body>
</html>