Thread overview
My vibe-d test app is crashing on Windows
Feb 13, 2023
Steve
Feb 13, 2023
ShadoLight
February 13, 2023

The app is just a test echo server. JSON sent in the body of a POST request is echoed back to the client. On Pop!_OS it works fine but on Windows it responds, there's a delay of about 10 seconds and then it crashes with the error:

Error Program exited with code -1073741819

Here's the code:

import vibe.vibe;
import std.json, std.stdio;

void main() {
	auto settings = new HTTPServerSettings;
	settings.port = 8080;
	settings.bindAddresses = ["::1", "127.0.0.1"];

    auto router = new URLRouter;
    router.get("*", serveStaticFiles("public/"));
    router.post("/", &onPost);

	auto listener = listenHTTP(settings, router);
	scope (exit) { listener.stopListening(); }

	logInfo("App listening at http://127.0.0.1:8080/");
	runApplication();
}

static string handlePost(string req) {
    return req;
}

void onPost(HTTPServerRequest req, HTTPServerResponse res) {
    try {
        auto jsr = async(&handlePost, req.json.toString()).getResult();
        res.contentType("application/json; charset=utf-8");
        res.writeBody(jsr);
    } catch (Exception e) {
        res.contentType("text/plain; charset=utf-8");
        res.writeBody(e.msg);
    }
}

Also when you launch/build the app with dub there's a shed load of deprecation warnings, e.g.:

\Local\dub\packages\vibe-d-0.9.5\vibe-d\stream\vibe\stream\wrapper.d(334,23): Deprecation: reference to local variable `this` assigned to non-scope parameter `bytes` calling `writeToStream`

I'm a D newbie so it's quite possibly something I'm doing wrong ...

February 13, 2023

On Monday, 13 February 2023 at 13:12:23 UTC, Steve wrote:

>

The app is just a test echo server. JSON sent in the body of a POST request is echoed back to the client. On Pop!_OS it works fine but on Windows it responds, there's a delay of about 10 seconds and then it crashes with the error:

Error Program exited with code -1073741819

Here's the code:

import vibe.vibe;
import std.json, std.stdio;

void main() {
	auto settings = new HTTPServerSettings;
	settings.port = 8080;
	settings.bindAddresses = ["::1", "127.0.0.1"];

    auto router = new URLRouter;
    router.get("*", serveStaticFiles("public/"));
    router.post("/", &onPost);

	auto listener = listenHTTP(settings, router);
	scope (exit) { listener.stopListening(); }

	logInfo("App listening at http://127.0.0.1:8080/");
	runApplication();
}

static string handlePost(string req) {
    return req;
}

void onPost(HTTPServerRequest req, HTTPServerResponse res) {
    try {
        auto jsr = async(&handlePost, req.json.toString()).getResult();
        res.contentType("application/json; charset=utf-8");
        res.writeBody(jsr);
    } catch (Exception e) {
        res.contentType("text/plain; charset=utf-8");
        res.writeBody(e.msg);
    }
}

Also when you launch/build the app with dub there's a shed load of deprecation warnings, e.g.:

\Local\dub\packages\vibe-d-0.9.5\vibe-d\stream\vibe\stream\wrapper.d(334,23): Deprecation: reference to local variable `this` assigned to non-scope parameter `bytes` calling `writeToStream`

I'm a D newbie so it's quite possibly something I'm doing wrong ...

The -1073741819 error is OxC0000005 in hex.

And C0000005 on Windows is a access violation exception, indicating that you are trying to access memory that doesn't belong to your process. Possibly a 'buffer overrun' access exception - but I'm not sure in this case.

Unfortunately I'm not experienced with vibe at all - so I can't help with your code.

Just google 'Windows error C0000005' for more info.

February 13, 2023

On 2/13/23 8:12 AM, Steve wrote:

>

The app is just a test echo server. JSON sent in the body of a POST request is echoed back to the client. On Pop!_OS it works fine but on Windows it responds, there's a delay of about 10 seconds and then it crashes with the error:

Error Program exited with code -1073741819

As mentioned, that's an access violation. So something is wrong in the vibe library on windows.

I confirmed it works fine for me on Linux.

Did you try without the async call? Try and reduce which part of it is causing the failure.

>

Also when you launch/build the app with dub there's a shed load of deprecation warnings, e.g.:

\Local\dub\packages\vibe-d-0.9.5\vibe-d\stream\vibe\stream\wrapper.d(334,23): Deprecation: reference to local variable `this` assigned to non-scope parameter `bytes` calling `writeToStream`

I'm a D newbie so it's quite possibly something I'm doing wrong ...

This is the hellscape that we are in for with dip1000 around the corner. It's not your fault, many many programs/libraries have not been updated to deal with dip1000, and it likely will be this way for a while.

-Steve