Search code examples
exceptiondvibed

Unable to throw exceptions in the delegate called by listenTCP function


Binary file produced from the following code works perfectly on one computer (Windows 8 x64) and crashes on another (Windows Server 2012 R2 Standard x64):

import std.stdio;

import vibe.vibe;

void new_request(TCPConnection conn)
{
  writeln("before");

  try
  {
    throw new Exception("Exception");
  }
  catch (Throwable ex)
  {
    writeln(ex.msg);
  }

  writeln("after");
}

void main()
{
  auto f = toDelegate(&new_request);
  listenTCP(1605, f);
  runEventLoop();
}

Output on Windows 8 x64

before
Exception
after

Output on Windows Server 2012 R2 Standard x64

before

And then crash.

It seems that I can't throw any exception in the delegate called by listenTCP function on some computers.

Is it a well-known behavior? Is it a bug? Should I report it to the vibe.d forum or somewhere else?

I'm using DMD 2.068.2, DUB 0.9.24 and vibe.d 0.7.24.

dub.json looks like this:

{
    "name": "vibe_helper",
    "dependencies": {
        "vibe-d": "==0.7.24"
    },
    "versions": ["VibeCustomMain"]
}

Solution

  • As a result of discussion on vibe.d official forum, it seems that this behavior related to the already opened issue for DMD.