3

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"]
}
Max Alibaev
  • 681
  • 7
  • 17
FrozenHeart
  • 19,844
  • 33
  • 126
  • 242
  • smells like a bug to me. I was prepared to come in here and warn that exceptions may propagate up through the event loop but since you caught it early, that doesn't seem to be the problem. Can you test a program on that Windows server that doesn't use vibe and only tries to throw and catch an exception? so like `void main() { try throw new Exception("foo"); catch(Exception e) {} }` then compile with plain `dmd yourfile.d` and see if it runs. – Adam D. Ruppe Nov 03 '15 at 22:42
  • @Adam D. Ruppe I already tried it -- throwing and catching exceptions anywhere else (in the main thread or in the thread created via `Thread` class) works as expected – FrozenHeart Nov 03 '15 at 22:44

1 Answers1

2

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

FrozenHeart
  • 19,844
  • 33
  • 126
  • 242