title: How to debug 'Stack smashing detected'?
body: <p>I have a complex c++ code.  It's a FastCGI program, using the <a href="http://althenia.net/fcgicc" rel="noreferrer">FastCGI C++ Class library</a>.</p>
  <p>When I ask it for a very looooong url, I get:</p>
  <pre><code>*** stack smashing detected ***: ./tileserve terminated
  Erreur de segmentation
  </code></pre>
  <p>For real life applications, it's not an issue since I never use so long URLs, but this means that anyone could terminate my server... I don't like that.</p>
  <p>Is there a tool to find out where this problem appears?  How do I use it?</p>
  <h2>EDIT: SOLVED</h2>
  <p>I was doing this:</p>
  <pre class="lang-cpp prettyprint-override"><code>int len;
  char uri[200];
  
  len = strlen(request.params[std::string(&quot;REQUEST_URI&quot;)].c_str());
  printf(&quot;%d\n&quot;, len);
  
  if (len &gt; 200) return 1;
  
  strcpy(uri, request.params[std::string(&quot;REQUEST_URI&quot;)].c_str());
  </code></pre>
  <p>Looks like <code>200</code> was too high for the <code>len</code> test.  It actually fails at <code>194</code>.</p>
  <p>So instead I did this:</p>
  <pre class="lang-cpp prettyprint-override"><code>if (len &gt; 190) return 1;
  </code></pre>
  <p>Now, it's fine.</p>