Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Possibly-related memory corruption issue #43

Open
Abscissa opened this issue Apr 25, 2019 · 3 comments
Open

Possibly-related memory corruption issue #43

Abscissa opened this issue Apr 25, 2019 · 3 comments

Comments

@Abscissa
Copy link

I guessing this is probably a dmd issue, and filed it as 19825. But I'm posting here too, just in case std_data_json is part of the problem, or anyone here could help find the exact compiler problem:

dub.sdl:

name "test"
dependency "std_data_json" version="==0.18.3"

main.d:

import std.stdio;
import stdx.data.json;

enum rawJson = `
{
	"rootPackage": "vibe-d",
	"targets": [
		{
			"rootConfiguration": "vibe-core"
		}
	]
}
`;

void yap(T...)(lazy T args)
{
	writeln(args);
}

struct Foo
{
	int a;
	string name;
}

Foo makeFoo()
{
	Foo foo;

	auto root = rawJson.toJSONValue;
	foo.name = root["rootPackage"].toString.idup;
	writeln(foo.name);
	yap(root["targets"][0]["rootConfiguration"]);

	return foo;
}

void main(string[] args)
{
	auto foo = makeFoo();
	writeln(foo.name); // Garbled output, then an exception
}

result:

$ dub -q
vibe-d
vibe-core
[...garbled data here...]uncaught exception
std.exception.ErrnoException@/home/nick/.dvm/compilers/dmd-2.085.0/linux/bin/../../src/phobos/std/stdio.d(2882): Enforcement failed (Bad address)
----------------
/home/nick/.dvm/compilers/dmd-2.085.0/linux/bin/../../src/phobos/std/exception.d:515 @safe void std.exception.bailOut!(std.exception.ErrnoException).bailOut(immutable(char)[], ulong, scope const(char)[]) [0xf11be9a1]
/home/nick/.dvm/compilers/dmd-2.085.0/linux/bin/../../src/phobos/std/exception.d:436 @safe int std.exception.enforce!(std.exception.ErrnoException).enforce!(int).enforce(int, lazy const(char)[], immutable(char)[], ulong) [0xf11be921]
/home/nick/.dvm/compilers/dmd-2.085.0/linux/bin/../../src/phobos/std/stdio.d:2882 @safe void std.stdio.File.LockingTextWriter.put!(immutable(char)[]).put(scope immutable(char)[]) [0xf11be81f]
/home/nick/.dvm/compilers/dmd-2.085.0/linux/bin/../../src/phobos/std/stdio.d:3806 @safe void std.stdio.writeln!(immutable(char)[]).writeln(immutable(char)[]) [0xf11be747]
src/main.d:41 _Dmain [0xf11a69d8]
Program exited with code -6
@s-ludwig
Copy link
Collaborator

It's not clear from the code, but it might be caused by s-ludwig/taggedalgebraic#29 - did you build with the latest 0.11.4 release?

@Abscissa
Copy link
Author

Hmm, it appears to be pulling in 0.10.13, not 0.11.4. Apparently the latest release of std_data_json (0.18.3) has its taggedalgebraic dependency set to ~>0.10.1. I tried manually editing dub.selections.json to 0.11.4, and I'm still getting the same issue, but I don't know whether dub might be just simply ignoring the 0.11.4 setting since it conflicts with the dependency constraints.

@FeepingCreature
Copy link

FeepingCreature commented Oct 17, 2019

Cannot reproduce here. Your dub.sdl is not enough to produce a working binary with dub 1.15.0/dmd 2.087.1. When I filled in the missing values, I did not get a crash. Is this still an issue?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants