[SERVER-7683] C++ driver segfaults with boost::thread Created: 15/Nov/12  Updated: 08/Mar/13  Resolved: 19/Nov/12

Status: Closed
Project: Core Server
Component/s: None
Affects Version/s: None
Fix Version/s: None

Type: Task Priority: Major - P3
Reporter: Shaun Verch Assignee: Unassigned
Resolution: Won't Fix Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Participants:

 Description   

Test program:

#include <boost/thread/thread.hpp>
#include <mongo/client/dbclient.h>
#include <mongo/client/connpool.h>

using namespace mongo;

void thread_run() {
DBClientConnection conn;
std::string errmsg;
if ( ! conn.connect( "127.0.0.1:27017" , errmsg ) )

{ cout << "couldn't connect : " << errmsg << endl; }

}

int main() {
boost::thread myThread(&thread_run);
myThread.interrupt();
myThread.join();
return 0;
}

Fails with either:
Segmentation fault: 11
or:
libc++abi.dylib: pure virtual method called
Abort trap: 6



 Comments   
Comment by Eric Milkie [ 19/Nov/12 ]

I played around with this a little. If you wait a little bit before you try to cancel the thread, you don't crash.
Thread cancellation is never easy to get correct, and it's a fact that the mongo code definitely does not support it.
Most people will argue that you have a design flaw if you are cancelling threads.

Comment by Eric Milkie [ 16/Nov/12 ]

When you say "-lboost_thread-mt", is that version 1.49?

Comment by Eric Milkie [ 15/Nov/12 ]

How did you build your test program?

Generated at Thu Feb 08 03:15:16 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.