On Sat, 23 Nov 2013 22:39:18 GMT, Atila Neves wrote:

Can you prepare a little (or large) test case, so that I can debug
locally? I think exit code -11 indicates a segmentation fault.

https://github.com/atilaneves/mqtt

Add "enableWorkerThreads()" and TCPListenOptions.distribute to mqttd/app.d, "dub" to run it then "telnet localhost 1883" with any input reproduces the problem. Comment out "enableWorkerThreads" and the app complains about an invalid message instead (since telnet isn't sending anything meaningful) and carries on. Put it back in and the complaint is still there but it exits soon thereafter.

Atila

Okay, the issue is that in your main code (app.d) gServer needs to be shared or __gshared for its value to be visible in threads other than the main thread. It is a null-dereference in line 26 that is responsible for the crash.

BTW I've just noticed that in package.json, there is "importPaths": ["mqttd"], but to match the module declarations in the actual D files, it needs to be "importPaths": ["."] (which then also makes the test/ files visible, which in turn is the reason why I'd always recommend a separate source folder for D projects). Otherwise there will be compile errors when it's used as a library and compiled separately (e.g. when "dub generate visuald" is used).