Bug creation and email sending has been disabled, file new bugs at gcc.gnu.org/bugzilla
Bug 146 - ICE (segmentation fault)
Summary: ICE (segmentation fault)
Status: RESOLVED FIXED
Alias: None
Product: GDC
Classification: Unclassified
Component: gdc (show other bugs)
Version: 4.9.x
Hardware: x86_64 Linux
: --- normal
Assignee: Iain Buclaw
URL:
Depends on:
Blocks:
 
Reported: 2014-07-23 13:17 CEST by Maor Ben Dayan
Modified: 2014-07-23 14:30 CEST (History)
1 user (show)

See Also:


Attachments
The code that breaks gdc (after reduction using Dumtmite), just untar and run 'gdc main.d bucket.d' (605 bytes, application/x-gzip)
2014-07-23 13:17 CEST, Maor Ben Dayan
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Maor Ben Dayan 2014-07-23 13:17:11 CEST
Created attachment 72 [details]
The code that breaks gdc (after reduction using Dumtmite), just untar and run 'gdc main.d bucket.d'

The attached reduced code (2 files) causes gdc on Linux/Intel 64bit to seg fault while dmd compiles the code (the non reduced code is also running fine).

output of 'gdc --version': gdc (Ubuntu 4.9.0-9ubuntu2) 4.9.0

the backtrace extracted by running 'gdc -wrapper gdb,--args main.d bucket.d -I.' :
(gdb) run
Starting program: /usr/lib/gcc/x86_64-linux-gnu/4.9/cc1d main.d -quiet -dumpbase main.d -mtune=generic -march=x86-64 -auxbase main -imultiarch x86_64-linux-gnu -I . -o /tmp/ccKYPvW3.s

Program received signal SIGSEGV, Segmentation fault.
0x000000000063ef14 in Type::baseElemOf() ()
(gdb) bt
#0  0x000000000063ef14 in Type::baseElemOf() ()
#1  0x00000000006bfbf8 in TypeFunction::toCtype() ()
#2  0x000000000068da35 in FuncDeclaration::toSymbol() ()
#3  0x00000000006c0432 in TypeClass::toCtype() ()
#4  0x000000000068f686 in declaration_type(Declaration*) ()
#5  0x0000000000692d78 in layout_aggregate_type(AggLayout*, AggregateDeclaration*) ()
#6  0x00000000006c0384 in TypeClass::toCtype() ()
#7  0x00000000006c0197 in TypePointer::toCtype() ()
#8  0x00000000006c370a in IndexExp::toElem(IRState*) ()
#9  0x00000000006c2bbc in AssignExp::toElem(IRState*) ()
#10 0x00000000006c4aec in Expression::toElemDtor(IRState*) ()
#11 0x00000000006c8ca8 in ExpStatement::toIR(IRState*) ()
#12 0x00000000006c8ba9 in CompoundStatement::toIR(IRState*) ()
#13 0x00000000006c8ba9 in CompoundStatement::toIR(IRState*) ()
#14 0x000000000069b6c5 in FuncDeclaration::toObjFile(int) ()
#15 0x000000000069a2bf in ClassDeclaration::toObjFile(int) ()
#16 0x000000000069cd4f in Module::genobjfile(int) ()
#17 0x000000000068ce28 in d_parse_file() ()
#18 0x0000000000997712 in ?? ()
#19 0x0000000000999310 in toplev_main(int, char**) ()
#20 0x00007ffff69e6ec5 in __libc_start_main (main=0x5a67d0 <main>, argc=15, 
    argv=0x7fffffffddd8, init=<optimized out>, fini=<optimized out>,
Comment 1 Ketmar Dark 2014-07-23 13:25:51 CEST
current dmd (latest git) fails to compile sample with this error message:

main.d(24): Error: AA key type TypedIdentifier should have 'size_t toHash() const nothrow @safe' if opEquals defined
Comment 2 Iain Buclaw 2014-07-23 14:16:28 CEST
(In reply to Ketmar Dark from comment #1)
> current dmd (latest git) fails to compile sample with this error message:
> 
> main.d(24): Error: AA key type TypedIdentifier should have 'size_t toHash()
> const nothrow @safe' if opEquals defined

Adding a toHash function still causes an ICE in GDC.
Comment 3 Ketmar Dark 2014-07-23 14:17:27 CEST
the source of the bug is in d-ctype.cc, in TypeFunction::toCtype().

there is this code: 'Type *tn = next->baseElemOf();', but 'next' can be NULL here due to code 'if (isref) ret_type = build_reference_type (ret_type);'.

there is the check for null before 'if' (and ret_type becomes void_type_node), but then build_reference_type changes ret_type to something another, and 'if (ret_type != void_type_node)' check fails.

it's easy to add some checks, but i don't understand gdc internals enough to decide where this check should go.


the problem is definitely in gdc backend, it's not frontend-related. let's wait for Iain then.