title: how to debug "Invalid parameter passed to C runtime function"?
body: <h1>Background</h1>
  <p>I've got about a terabyte of files with raw data, with a relatively small subset of labelled data. I've written c++ code (calling some ancient MSVC++2003 code I heavily modified to get it to compile on recent compilers) to aggregate the annotated data slices.</p>
  <p>A big part of that labelled data is concentrated in one file, but that file turns out to be the one where my program crashes.</p>
  <h1>Problem</h1>
  <p>I'm getting</p>
  <pre><code>Invalid parameter passed to C runtime function.
  Invalid parameter passed to C runtime function.
  terminate called after throwing an instance of 'int'
  </code></pre>
  <p>In my Qt output window, and windows tells me the same in a popup, but at this point it's too late to get any useful info out of the executable / debugger it seems (though I'm not experienced at all with Qt's debugger).</p>
  <h1>What I have tried</h1>
  <p>I've googled all over and found plenty of people with this error message but it's so generic that none of their issues could be the same as mine, and there's such a long list of different C runtime functions that sifting through all of them is slow and it doesn't seem to help.</p>
  <h1>My question</h1>
  <p>&quot;Find a man a bug, and you help him for a day. Teach a man to debug and you help him for a lifetime. Post the way on stackoverflow and you help many men and get a lot of upvotes.&quot;</p>
  <p>Is there a generic method to find what C runtime function the problem was and what the argument was? Did I miss some fancy debugger features? Is there anything else you could recommend or info I could provide?</p>
  <p>I'd hope to get a catch-all answer to this to help everyone with this problem, not just me, but I'll be glad if I'm helped too of course.</p>
  <h1>Specific to my problem:</h1>
  <p>My stack trace is as follows:</p>
  <p>0   ntdll!DbgBreakPoint         0x7727000d<br />
  1   ntdll!DbgUiRemoteBreakin            0x772ff156<br />
  2   ??          0x6f06eaa1<br />
  3   KERNEL32!BaseThreadInitThunk            0x7501338a<br />
  4   ntdll!RtlInitializeExceptionChain           0x77299902<br />
  5   ntdll!RtlInitializeExceptionChain           0x772998d5<br />
  6   ??</p>
  <p><strike>and gdb can't get a better trace it seems (anything I try to do with it gets me a timeout error).</strike></p>
  <p>After trying a couple more functions just to be sure everything gave a timeout trying &quot;backtrace&quot; once again did give me a result. I guess I just never put this much time in gdb after it timeouting on me once.</p>
  <p>That said, I <em>might</em> be able to find something with this new info. Consider my specific problem closed, but my general point is still valid I believe: I've now found the function with the problem (I think), but not why it is a problem, nor what the invalid parameter is. Even better, I've traced it to a line where it says &quot;throw 1&quot;. So now I'm assuming windows/Qt translates that to the &quot;invalid parameter&quot;. But it's not true.</p>
  <h1>It can just be some bad code, it does not even need to be a C function, and nothing needs to be wrong with your parameters.</h1>
  <p>...</p>
  <p>#17 0x00c17d72 in libstdc++-6!.cxa_throw () from C:\Qt\5.5\mingw492_32\bin\libstdc++-6.dll
  No symbol table info available.
  ...</p>