Am 24.07.2012 19:17, schrieb David Eagen:

I've been trying to track down a crash in my app.

I am spawning a thread that I want to use to record statistics
information for each request to a MongoDB database. I send it messages
with a struct containing the information to log.

But, it crashes every time on the insert. If I call the exact same
function from the handler thread instead of sending the data in a
message to the logging thread I do not get the crash.

Here are the last few lines from gdb analyzing the core:

#0 0x000000000052f61f in vibe.core.tcp.connectTcp() ()
#1 0x000000000059cda0 in TMP898 ()<br>#2 0x00007ff3a7b1bff0 in ?? ()<br>#3 0x0000000000559165 in gcmalloc ()
#4 0x0000000000542f27 in
vibe.db.mongo.connection.MongoConnection.connect() ()

I modified connectTcp to make sure values were legit:

 import std.exception;
 import std.string;
 auto driver = getEventDriver();
 enforce(driver !is null, "Event driver is null.");
 enforce(port != 0, "Port shouldn't  be 0.");
 enforce(cmp(host, "") != 0, "host shouldn't be emtpy.");

 return driver.connectTcp(host, port);

Sure enough, the event driver is null:

[7FD19483D4D1:00000000 ERR] Unable to record performance information for
/man. Error was: Event driver is null.

Am I doing something really wrong? Or should I open a bug?

-Dave

The current version is not yet multi-thread capable as-is (regarding
I/O). There is an experimental switch (-version=MultiThreadTest) but
that has been tested only very briefly for benchmarking purposes and
will likely also fail.

For now I would use startTask() to start a fiber instead of a thread.
You can use createSignal() to create a cross-fiber signal (basically a
condition variable) to notify the logging fiber for new messages.

But for the next version I hope to get some basic multi-threading
support ready.