title: Strange spontaneous run crash
body: <p>I'm getting some strange errors and crashes from my project atm.</p>
  
  <p>It started out with crashes where I got this message:</p>
  
  <pre><code>terminate called after throwing an instance of 'std::length_error'
    what():  basic_string::_S_create
  </code></pre>
  
  <p>So I started adding some <strong>cerr &lt;&lt; "1"</strong> etc to try and find at what line it crashed.</p>
  
  <p>Now I've found the crash-line, allthough it doesn't print out the same error code. In fact, it doesn't say anything, just crash.</p>
  
  <p>The line that causes the crash is this:</p>
  
  <pre><code>Item* tempItem = new Item(name, id2, desc);
  </code></pre>
  
  <p>Item.h constructor looks like this:</p>
  
  <pre><code>Item(std::string name_, int itemId_, std::string description_ = "") 
  : name(name_), itemId(itemId_), description(description_){}
  </code></pre>
  
  <p>and the variables I'm sending in looks like this:</p>
  
  <pre><code>string name = "Frying pan";
  int id2 = 1;
  string desc = "It's all rusty";
  </code></pre>
  
  <p>any ideas? (If you need more code just tell me what you need and I'll edit it in)</p>
  
  <p><strong>EDIT</strong>
  some updated info:</p>
  
  <pre><code>name.max_size() = 1073741820
  name.length() = 9
  
  desc.max_size() = 1073741820
  desc.length() = 14
  </code></pre>
  
  <p><strong>EDIT2</strong>
  I've now tried creating the Item-objects with hard coding the variable values right before construction as such:</p>
  
  <pre><code>name = "itemName";
  desc = "itemDesc";
  id2 = 2;
  </code></pre>
  
  <p>and it STILL crashes right at the line:</p>
  
  <pre><code>Item* tempItem = new Item(name, id2, desc);
  </code></pre>