Note that there are some explanatory texts on larger screens.

plurals
  1. POLinux Segmentation fault with std::string::iterator
    primarykey
    data
    text
    <p>I keep getting unusual segmentation faults inside libc.so.6 on a CentOS 6.4 64bit machine. This is the backtrace that gdb most often reports:</p> <pre><code>0x00007ffff60d9b3f in memcpy () from /lib64/libc.so.6 (gdb) backtrace #0 0x00007ffff60d9b3f in memcpy () from /lib64/libc.so.6 #1 0x00000000004b6a6b in std::string::_S_construct&lt;__gnu_cxx::__normal_iterator&lt;char*, std::string&gt; &gt; () #2 0x00000000004b719b in NewsMAIL::SMTPClient::receiveLine(std::basic_string&lt;char, std::char_traits&lt;char&gt;, std::allocator&lt;char&gt; &gt;*) () #3 0x00000000004b776f in NewsMAIL::SMTPClient::handleResponse() () </code></pre> <p>And this is the code in question that seems to trigger the segfault:</p> <pre><code>bool SMTPClient::receiveLine(std::string* Line) { static std::string Buffer; std::string::iterator iter; while((iter = std::find(Buffer.begin(), Buffer.end(), '\n')) == Buffer.end()) { char Bucket[MAX_BUCKET_SIZE + 1] = {}; int BytesRecv = read(m_Socket, Bucket, MAX_BUCKET_SIZE); //Did we get a socket error? if(BytesRecv == -1) { //This is generally considered a bad thing.. *Line = Buffer; Buffer = std::string(""); return false; } Bucket[BytesRecv] = 0; Buffer += Bucket; } *Line = std::string(Buffer.begin(), iter); Buffer = std::string(iter + 1, Buffer.end()); return true; } </code></pre> <p>Sometimes it works 100% without any failures so it is not everytime unfortunately. The above code is a slightly modified version of this: <a href="https://stackoverflow.com/a/1584620/3133245">https://stackoverflow.com/a/1584620/3133245</a></p> <p>Does anyone have any thoughts on why this might be happening? I am compiling with g++ 4.7.2</p> <p>Thanks!</p> <p>Nate</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload