Jump to page: 1 2
Thread overview
Got compiler crash in Mangler::mangleFuncType
Mar 25, 2017
Uranuz
Mar 25, 2017
Uranuz
Mar 25, 2017
Nicholas Wilson
Mar 25, 2017
Uranuz
Mar 25, 2017
Jacob Carlborg
Mar 25, 2017
Stefan Koch
Mar 25, 2017
Uranuz
Mar 25, 2017
Stefan Koch
Mar 25, 2017
Uranuz
Mar 25, 2017
Nicholas Wilson
Mar 25, 2017
Jacob Carlborg
Mar 25, 2017
Uranuz
Mar 25, 2017
Stefan Koch
Mar 25, 2017
Uranuz
Mar 25, 2017
Stefan Koch
Mar 25, 2017
Uranuz
Mar 25, 2017
Stefan Koch
Mar 25, 2017
Uranuz
Mar 25, 2017
Stefan Koch
March 25, 2017
After changes in my project tried to compile, but compiler failed. Running dmd under GDB gives the following:
Program received signal SIGSEGV, Segmentation fault.
0x00000000005807a0 in Mangler::mangleFuncType(TypeFunction*, TypeFunction*, unsigned char, Type*) ()

Could someone give me adivice how to investigate and maybe fix this problem?

March 25, 2017
On Saturday, 25 March 2017 at 06:56:40 UTC, Uranuz wrote:
> After changes in my project tried to compile, but compiler failed. Running dmd under GDB gives the following:
> Program received signal SIGSEGV, Segmentation fault.
> 0x00000000005807a0 in Mangler::mangleFuncType(TypeFunction*, TypeFunction*, unsigned char, Type*) ()
>
> Could someone give me adivice how to investigate and maybe fix this problem?

Tried to build DMD from source using manual:
https://wiki.dlang.org/Building_under_Posix

Running compiled DMD to build my project gives the following error:
core.exception.AssertError@ddmd/func.d(1641): Assertion failure
----------------
??:? _d_assert [0x71c730]
??:? void ddmd.func.__assert(int) [0x5b52de]
??:? _ZN15FuncDeclaration9semantic3EP5Scope [0x5ab904]
??:? _ZN20AggregateDeclaration9semantic3EP5Scope [0x500a1f]
??:? _ZN16TemplateInstance9semantic3EP5Scope [0x5705fd]
??:? _ZN6Module9semantic3EP5Scope [0x552b19]
??:? int ddmd.mars.tryMain(ulong, const(char)**) [0x5da406]
??:? _Dmain [0x5db2c6]
??:? _D2rt6dmain211_d_run_mainUiPPaPUAAaZiZ6runAllMFZ9__lambda1MFZv [0x71e5d7]
??:? void rt.dmain2._d_run_main(int, char**, extern (C) int function(char[][])*).tryExec(scope void delegate()) [0x71e503]
??:? void rt.dmain2._d_run_main(int, char**, extern (C) int function(char[][])*).runAll() [0x71e57c]
??:? void rt.dmain2._d_run_main(int, char**, extern (C) int function(char[][])*).tryExec(scope void delegate()) [0x71e503]
??:? _d_run_main [0x71e467]
??:? main [0x5dba67]
??:? __libc_start_main [0x2c5a82f]
March 25, 2017
On Saturday, 25 March 2017 at 06:56:40 UTC, Uranuz wrote:
> After changes in my project tried to compile, but compiler failed. Running dmd under GDB gives the following:
> Program received signal SIGSEGV, Segmentation fault.
> 0x00000000005807a0 in Mangler::mangleFuncType(TypeFunction*, TypeFunction*, unsigned char, Type*) ()
>
> Could someone give me adivice how to investigate and maybe fix this problem?

Switched to v2.073.2. Used this built version of compiler and got some additional messages from compiler:
src/mkk_site/view_service/access_control.d(25): Deprecation: mkk_site.view_service.utils.HTTPContext is not visible from module access_control
../ivy/src/ivy/interpreter.d-mixin-670(670): Error: undefined identifier '__cmp' in module 'object'
../ivy/src/ivy/interpreter.d-mixin-670(670): Error: undefined identifier '__cmp' in module 'object'
../ivy/src/ivy/interpreter.d-mixin-670(670): Error: undefined identifier '__cmp' in module 'object'
../ivy/src/ivy/interpreter.d-mixin-670(670): Error: undefined identifier '__cmp' in module 'object'
core.exception.AssertError@ddmd/func.d(1641): Assertion failure
----------------
??:? _d_assert [0x71c730]
??:? void ddmd.func.__assert(int) [0x5b52de]
??:? _ZN15FuncDeclaration9semantic3EP5Scope [0x5ab904]
??:? _ZN20AggregateDeclaration9semantic3EP5Scope [0x500a1f]
??:? _ZN16TemplateInstance9semantic3EP5Scope [0x5705fd]
??:? _ZN6Module9semantic3EP5Scope [0x552b19]
??:? int ddmd.mars.tryMain(ulong, const(char)**) [0x5da406]
??:? _Dmain [0x5db2c6]
??:? _D2rt6dmain211_d_run_mainUiPPaPUAAaZiZ6runAllMFZ9__lambda1MFZv [0x71e5d7]
??:? void rt.dmain2._d_run_main(int, char**, extern (C) int function(char[][])*).tryExec(scope void delegate()) [0x71e503]
??:? void rt.dmain2._d_run_main(int, char**, extern (C) int function(char[][])*).runAll() [0x71e57c]
??:? void rt.dmain2._d_run_main(int, char**, extern (C) int function(char[][])*).tryExec(scope void delegate()) [0x71e503]
??:? _d_run_main [0x71e467]
??:? main [0x5dba67]
??:? __libc_start_main [0xcc85082f]
March 25, 2017
On Saturday, 25 March 2017 at 07:16:34 UTC, Uranuz wrote:
> On Saturday, 25 March 2017 at 06:56:40 UTC, Uranuz wrote:
>> [...]
>
> Tried to build DMD from source using manual:
> https://wiki.dlang.org/Building_under_Posix
>
> [...]

try using Dustmite (https://github.com/CyberShadow/DustMite/) to reduce your project to the minimal amount that still reproduces the crash.
March 25, 2017
On Saturday, 25 March 2017 at 06:56:40 UTC, Uranuz wrote:
> After changes in my project tried to compile, but compiler failed. Running dmd under GDB gives the following:
> Program received signal SIGSEGV, Segmentation fault.
> 0x00000000005807a0 in Mangler::mangleFuncType(TypeFunction*, TypeFunction*, unsigned char, Type*) ()
>
> Could someone give me adivice how to investigate and maybe fix this problem?

Switch to git ~master and see if it still occurs.
Also if you can share the source I am happy to debug this.
March 25, 2017
On Saturday, 25 March 2017 at 07:57:11 UTC, Stefan Koch wrote:
> On Saturday, 25 March 2017 at 06:56:40 UTC, Uranuz wrote:
>> After changes in my project tried to compile, but compiler failed. Running dmd under GDB gives the following:
>> Program received signal SIGSEGV, Segmentation fault.
>> 0x00000000005807a0 in Mangler::mangleFuncType(TypeFunction*, TypeFunction*, unsigned char, Type*) ()
>>
>> Could someone give me adivice how to investigate and maybe fix this problem?
>
> Switch to git ~master and see if it still occurs.
> Also if you can share the source I am happy to debug this.

I just put debug messages on every `assert` and figured out it fails on lines:
                    bool implicit0 = (f.next.ty == Tvoid && isMain());
                    Type tret = implicit0 ? Type.tint32 : f.next;
                    assert(tret.ty != Tvoid);
                    if (vresult || returnLabel)
                        buildResultVar(scout ? scout : sc2, tret);
I really don't understand what it is... Now I cannot share codebase easily. Seems that it fails on my programme `main` function or near that, because compiler stack not so deep. There is some check for isMain AFAIK... What is this about?
March 25, 2017
On Saturday, 25 March 2017 at 08:13:08 UTC, Uranuz wrote:
> On Saturday, 25 March 2017 at 07:57:11 UTC, Stefan Koch wrote:
>> [...]
>
> I just put debug messages on every `assert` and figured out it fails on lines:
>                     bool implicit0 = (f.next.ty == Tvoid && isMain());
>                     Type tret = implicit0 ? Type.tint32 : f.next;
>                     assert(tret.ty != Tvoid);
>                     if (vresult || returnLabel)
>                         buildResultVar(scout ? scout : sc2, tret);
> I really don't understand what it is... Now I cannot share codebase easily. Seems that it fails on my programme `main` function or near that, because compiler stack not so deep. There is some check for isMain AFAIK... What is this about?

are you creating a function called main ?
that would be about the only time this would be triggered.
March 25, 2017
On Saturday, 25 March 2017 at 08:13:08 UTC, Uranuz wrote:
> On Saturday, 25 March 2017 at 07:57:11 UTC, Stefan Koch wrote:
>> On Saturday, 25 March 2017 at 06:56:40 UTC, Uranuz wrote:
>>> [...]
>>
>> Switch to git ~master and see if it still occurs.
>> Also if you can share the source I am happy to debug this.
>
> I just put debug messages on every `assert` and figured out it fails on lines:
>                     bool implicit0 = (f.next.ty == Tvoid && isMain());
>                     Type tret = implicit0 ? Type.tint32 : f.next;
>                     assert(tret.ty != Tvoid);
>                     if (vresult || returnLabel)
>                         buildResultVar(scout ? scout : sc2, tret);
> I really don't understand what it is... Now I cannot share codebase easily.

dust mite has an "--obfuscate" option exactly for when you can't share the code.
see also the relevant section of the dust mite wiki
https://github.com/CyberShadow/DustMite/wiki/Detecting-a-segfault-in-dmd-itself

> Seems that it fails on my programme `main` function or near that, because compiler stack not so deep. There is some check for isMain AFAIK... What is this about?
March 25, 2017
On Saturday, 25 March 2017 at 08:24:04 UTC, Stefan Koch wrote:
> On Saturday, 25 March 2017 at 08:13:08 UTC, Uranuz wrote:
>> On Saturday, 25 March 2017 at 07:57:11 UTC, Stefan Koch wrote:
>>> [...]
>>
>> I just put debug messages on every `assert` and figured out it fails on lines:
>>                     bool implicit0 = (f.next.ty == Tvoid && isMain());
>>                     Type tret = implicit0 ? Type.tint32 : f.next;
>>                     assert(tret.ty != Tvoid);
>>                     if (vresult || returnLabel)
>>                         buildResultVar(scout ? scout : sc2, tret);
>> I really don't understand what it is... Now I cannot share codebase easily. Seems that it fails on my programme `main` function or near that, because compiler stack not so deep. There is some check for isMain AFAIK... What is this about?
>
> are you creating a function called main ?
> that would be about the only time this would be triggered.

Seems that compiler thinks that `struct` constructor returns some value, but declared type of return value for struct ctor is Tvoid, so it fails on assert. Printing returns.toChars() after condition `if (returns)`  gives `[return this;`. Maybe `returns` should be null there or not? I'm very confident that it fails on constructor. Tried to reduce example manually (I'm not very confident about Dustmite). But it doesn't reproduce error:

import std.stdio;

struct DirValueAttr(bool isForCompiler = false)
{
	string name;
	string typeName;

	static if( isForCompiler )
	{
		import ivy.node: IExpression;

		IExpression defaultValueExpr;
		this( string name, string typeName, IExpression defValue )
		{
			this.name = name;
			this.typeName = typeName;
			this.defaultValueExpr = defValue;
		}
	}
	else
	{
		this( string name, string typeName )
		{
			this.name = name;
			this.typeName = typeName;
		}
	}

	DirValueAttr!(false) toInterpreterValue() {
		return DirValueAttr!(false)(name, typeName);
	}
}

// We pass callable attributes by blocks. Every attribute block has size an type
// Size and type stored in single integer argument in stack preceding the block
// Size is major binary part of this integer denoted by bit offset:
enum size_t _stackBlockHeaderSizeOffset = 4;
// To have some validity check bit between size and block type must always be zero
// The following mask is used to check for validity:
enum size_t _stackBlockHeaderCheckMask = 0b1000;
// And there is mask to extract type of block
enum size_t _stackBlockHeaderTypeMask = 0b111;


enum DirAttrKind { NamedAttr, ExprAttr, IdentAttr, KwdAttr, BodyAttr };

static this()
{
	static assert( DirAttrKind.max <= _stackBlockHeaderTypeMask, `DirAttrKind set of values exeeded of defined limit` );
}

struct DirAttrsBlock(bool isForCompiler = false)
{
	import std.typecons: Tuple, tuple;
	alias TValueAttr = DirValueAttr!(isForCompiler);

	static if( isForCompiler ) {
		import ivy.node: ICompoundStatement;
		alias TBodyTuple = Tuple!(ICompoundStatement, "ast", bool, "isNoscope");
	}
	else {
		alias TBodyTuple = Tuple!(bool, "isNoscope");
	}

	static struct Storage {
		union {
			TValueAttr[string] namedAttrs;
			TValueAttr[] exprAttrs;
			string[] names;
			string keyword;
			TBodyTuple bodyAttr;
		}
	}

	private DirAttrKind _kind;
	private Storage _storage;

	this( DirAttrKind attrKind, TValueAttr[string] attrs )
	{
		assert( attrKind == DirAttrKind.NamedAttr, `Expected NamedAttr kind for attr block` );

		_kind = attrKind;
		_storage.namedAttrs = attrs;
	}

	this( DirAttrKind attrKind, TValueAttr[] attrs )
	{
		assert( attrKind == DirAttrKind.ExprAttr, `Expected ExprAttr kind for attr block` );

		_kind = attrKind;
		_storage.exprAttrs = attrs;
	}

	this( DirAttrKind attrKind, string[] names )
	{
		assert( attrKind == DirAttrKind.IdentAttr, `Expected IdentAttr kind for attr block` );

		_kind = attrKind;
		_storage.names = names;
	}

	this( DirAttrKind attrKind, string kwd )
	{
		assert( attrKind == DirAttrKind.KwdAttr, `Expected Keyword kind for attr block` );

		_kind = attrKind;
		_storage.keyword = kwd;
	}

	this( DirAttrKind attrKind, TBodyTuple value )
	{
		assert( attrKind == DirAttrKind.BodyAttr, `Expected BodyAttr kind for attr block` );

		_kind = attrKind;
		_storage.bodyAttr = value;
	}

	this( DirAttrKind attrKind )
	{
		_kind = attrKind;
	}

	DirAttrKind kind() @property {
		return _kind;
	}

	void kind(DirAttrKind value) @property {
		_kind = value;
	}

	void namedAttrs( TValueAttr[string] attrs ) @property {
		_storage.namedAttrs = attrs;
		_kind = DirAttrKind.NamedAttr;
	}

	TValueAttr[string] namedAttrs() @property {
		assert( _kind == DirAttrKind.NamedAttr, `Directive attrs block is not of NamedAttr kind` );
		return _storage.namedAttrs;
	}

	void exprAttrs( TValueAttr[] attrs ) @property {
		_storage.exprAttrs = attrs;
		_kind = DirAttrKind.ExprAttr;
	}

	TValueAttr[] exprAttrs() @property {
		assert( _kind == DirAttrKind.ExprAttr, `Directive attrs block is not of ExprAttr kind` );
		return _storage.exprAttrs;
	}

	void names(string[] names) @property {
		_storage.names = names;
		_kind = DirAttrKind.IdentAttr;
	}

	string[] names() @property {
		assert( _kind == DirAttrKind.IdentAttr, `Directive attrs block is not of IdentAttr kind` );
		return _storage.names;
	}

	void keyword(string value) @property {
		_storage.keyword = value;
		_kind = DirAttrKind.KwdAttr;
	}

	string keyword() @property {
		assert( _kind == DirAttrKind.KwdAttr, `Directive attrs block is not of KwdAttr kind` );
		return _storage.keyword;
	}

	void bodyAttr(TBodyTuple value) @property {
		_storage.bodyAttr = value;
		_kind = DirAttrKind.BodyAttr;
	}

	TBodyTuple bodyAttr() @property {
		assert( _kind == DirAttrKind.BodyAttr, `Directive attrs block is not of BodyAttr kind` );
		return _storage.bodyAttr;
	}

	DirAttrsBlock!(false) toInterpreterBlock()
	{
		import std.algorithm: map;
		import std.array: array;

		final switch( _kind )
		{
			case DirAttrKind.NamedAttr: {
				DirValueAttr!(false)[string] attrs;
				foreach( key, ref currAttr; _storage.namedAttrs ) {
					attrs[key] = currAttr.toInterpreterValue();
				}
				return DirAttrsBlock!(false)( _kind, attrs );
			}
			case DirAttrKind.ExprAttr:
				return DirAttrsBlock!(false)( _kind, _storage.exprAttrs.map!( a => a.toInterpreterValue() ).array );
			case DirAttrKind.IdentAttr:
				return DirAttrsBlock!(false)( _kind, _storage.names );
			case DirAttrKind.KwdAttr:
				return DirAttrsBlock!(false)( _kind, _storage.keyword );
			case DirAttrKind.BodyAttr:
				return DirAttrsBlock!(false)( _kind, tuple!("isNoscope")(_storage.bodyAttr.isNoscope) );
		}
		assert( false, `This should never happen` );
	}

	string toString()
	{
		import std.conv: to;
		final switch( _kind ) with( DirAttrKind )
		{
			case NamedAttr:
			case ExprAttr:
			case IdentAttr:
			case KwdAttr:
			case BodyAttr:
				return `<` ~ _kind.to!string ~ ` attrs block>`;
		}
	}
}
void func() {
	DirAttrsBlock!(false)[] _attrBlocks = [
		DirAttrsBlock!false( DirAttrKind.NamedAttr, [
			"__result__": DirValueAttr!(false)( "__result__", "any" )
		]),
		DirAttrsBlock!false( DirAttrKind.BodyAttr )
	];

}

void main()
{
	func();

}
In full project it fails on `this( DirAttrKind attrKind, TValueAttr[string] attrs )` ctor.
March 25, 2017
On Saturday, 25 March 2017 at 07:57:11 UTC, Stefan Koch wrote:
> On Saturday, 25 March 2017 at 06:56:40 UTC, Uranuz wrote:
>> After changes in my project tried to compile, but compiler failed. Running dmd under GDB gives the following:
>> Program received signal SIGSEGV, Segmentation fault.
>> 0x00000000005807a0 in Mangler::mangleFuncType(TypeFunction*, TypeFunction*, unsigned char, Type*) ()
>>
>> Could someone give me adivice how to investigate and maybe fix this problem?
>
> Switch to git ~master and see if it still occurs.
> Also if you can share the source I am happy to debug this.

If you wish to help. You are welcome) I created branch in my repository `https://github.com/uranuz/ivy` called `v0.1/fail_on_compiler_error`. Seems that error depends on the order of source files that were passed to DMD. The way that error occurs is using RDMD utility, by running command(in project root folder):
rdmd "-Isrc/" -ofsimple_run_test test/simple_run_test.d

But if I run it using `dub` it compiles successfully(config is in dub.json):
dub run -c simple_run_test

Printing actual dmd command, used to compile project shows that dub puts `simple_run_test.d` at the end of source files list, but rdmd puts it at the beginning. And DMD fails in the first case without printing any adequate error message? Is there any ideas about it, besides using `dub` everywhere?)..

« First   ‹ Prev
1 2