Wiki Roadmap Timeline Tickets New Ticket Source Search Help / Guide About Trac Login

Ticket #272 (closed defect: fixed)

Opened 3 years ago

Last modified 3 years ago

crash in classes.cpp:449

Reported by: mwarning Assigned to: ChristianK
Priority: major Milestone:
Component: unspecified Version: hg tip
Keywords: Cc:

Description

This error occurs when compiling http://titanion.sourceforge.net. It's the same for some other application that compiled fine before with an older ldc version.

ldc: /opt/ldc/gen/classes.cpp:449: llvm::Value* DtoIndexClass(llvm::Value*, ClassDeclaration*, VarDeclaration*): Assertion `field' failed.
0   ldc             0x0000000000d6aa7f
1   ldc             0x0000000000d6ae79
2   libpthread.so.0 0x00002b9c0fc9e7b0
3   libc.so.6       0x00002b9c10aa0105 gsignal + 53
4   libc.so.6       0x00002b9c10aa1623 abort + 387
5   libc.so.6       0x00002b9c10a99149 __assert_fail + 233
6   ldc             0x0000000000621613 DtoIndexClass(llvm::Value*, ClassDeclaration*, VarDeclaration*) + 883
7   ldc             0x000000000064df7a DotVarExp::toElem(IRState*) + 346
8   ldc             0x000000000064f4af AssignExp::toElem(IRState*) + 175
9   ldc             0x00000000005edccc ExpStatement::toIR(IRState*) + 108
10  ldc             0x00000000005edae9 CompoundStatement::toIR(IRState*) + 89
11  ldc             0x00000000005edae9 CompoundStatement::toIR(IRState*) + 89
12  ldc             0x000000000066e70e DtoDefineFunction(FuncDeclaration*) + 1902
13  ldc             0x0000000000675099 Ir::emitFunctionBodies() + 57
14  ldc             0x0000000000616819 Module::genLLVMModule(Ir*) + 665
15  ldc             0x000000000060b07d main + 5789
16  libc.so.6       0x00002b9c10a8c5a6 __libc_start_main + 230
17  ldc             0x000000000055a339
make: *** [ldc-linux] Aborted

ldc trunk and llvm trunk on x64 and x32.

Change History

04/27/09 20:58:48 changed by wilsonk

I get this from the -vv output:

 * * * * * * Building type: void function(Vector3 ringOfs, Vector3 centerPos, \
float rad, float d1, float d2)
* * * * * * * Building type: void(Vector3 ringOfs, Vector3 centerPos, float rad\
, float d1, float d2)
* * * * * * * isMember = this is: src.ttn.field.Field
* * * * * * * DtoFunctionType(void(Vector3 ringOfs, Vector3 centerPos, float ra\
d, float d1, float d2))
* * * * * * * * Putting 'this' in register
* terminate called after throwing an instance of 'std::bad_alloc'
  what():  std::bad_alloc
* * * * * * Adding type of src.ttn.field.Field.eyePos
* * * * * * * Building type: Vector3 function()
* * * * * * * Building type: Vector3()

so std::bad_alloc is called???

Thanks, K.Wilson

04/28/09 09:37:00 changed by mandel

Maybe it's related that the -vv output has lines of ~90MB size.
I interrupted the compilation when the log file grow to 2GB.

04/28/09 12:15:36 changed by lindquist

-vv really is meant for debuggin small test cases. Some class types, translated to llvm, require several mb to print as text when fully unwrapped (resolved completely down to basic types).

std::bad_alloc is most likely a -vv problem as mandel noted.

04/28/09 12:54:19 changed by lindquist

I'm having trouble getting all the dependencies (read derelict) working, could someone provide a single source file that exposes this issue? it doesn't have to be tiny.

alternatively, with a debug build of ldc, compile the offending file via gdb --args ldc foo.d -c, enter the DtoIndexClass? frame, enter the command p vd->toPrettyChars() and tell me what kind of member this is.

gdb is your friend! this is likely easy to fix with a proper testcase.

04/28/09 20:36:00 changed by mandel

I compiled another (similar) project that also shows this problem when I use a Makefile, but doesn't have any forward reference problems. ldc with rebuild works fine. When I pass all files in one line and try to pinpoint the crash I get the logger.d file (very similar project :P) and have to remove Stdout; after this, the crash occurs somewhere else.

04/29/09 17:01:49 changed by mandel

Ok, I got a testcase.

main.d:

module main;

void main()
{
}

Foo.d:

module Foo;

Bar.d:

module Bar;

import tango.io.Stdout;

void bar() {
	Stdout("Hello World").newline;
}
ldc  main.d Foo.d Bar.d  -ofmain

04/30/09 03:25:06 changed by wilsonk

The above short example fails on my Ubuntu8.04 x64 with ldc rev1279, llvm trunk and tango trunk. Actually I don't need the Foo.d file and I still get the failure.

This failure (DtoIndexClass?) is file order dependent. If you have 'ldc Bar.d main.d' then things compile but if you add the '-ofmain' then it fails again...or if you reverse the file order it fails to compile.

Thanks, K.Wilson

04/30/09 07:46:01 changed by lindquist

so... does it work if you compile each file seperately ?

04/30/09 07:55:06 changed by lindquist

I think the problem is that fields are set in the type resolver, however, between the modules all the fields are again reset to null, but ... the type resolver is not run again.

I really should fix more-at-once compilation for good ...

04/30/09 09:42:09 changed by mandel

It does work with separate compilation (using rebuild).

05/06/09 20:10:35 changed by lindquist

  • status changed from new to closed.
  • resolution set to fixed.

Fixed in rev 1309

Copyright © 2008, LDC Development Team.