Okay, the issue is that in your main code (app.d)
gServer
needs to beshared
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.
Oops. I feel silly now. Thanks!
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).
I don't want the tests directory to be visible actually. I run them separately with my tool dtest from unit_threaded. All I want to go into the lib is in mqttd.