Bug creation and email sending has been disabled, file new bugs at gcc.gnu.org/bugzilla
Bug 17 - Nasty interface contract bug
Summary: Nasty interface contract bug
Status: RESOLVED FIXED
Alias: None
Product: GDC
Classification: Unclassified
Component: gdc (show other bugs)
Version: development
Hardware: All All
: --- critical
Assignee: Iain Buclaw
URL:
Depends on:
Blocks:
 
Reported: 2012-10-21 15:37 CEST by Alex Rønne Petersen
Modified: 2013-05-14 23:08 CEST (History)
1 user (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Alex Rønne Petersen 2012-10-21 15:37:59 CEST
I could not reproduce this bug outside of MCI, but here are the instructions to do so in MCI for what it's worth:

$ git clone git://github.com/lycus/mci.git
$ ./bootstrap.py
$ ./waf configure --check-d-compiler=gdc
$ ./waf build
$ ./waf test

This last step is going to fail. Fire up GDB:

$ gdb --args ./build/mci asm tests/assembler/pass/test0.ial -o tests/assembler/pass/test0.mci -d tests/assembler/pass/test0.ast

(gdb) run
Starting program: /home/alexrp/Projects/mci/build/mci asm tests/assembler/pass/test0.ial -o tests/assembler/pass/test0.mci -d tests/assembler/pass/test0.ast
[Thread debugging using libthread_db enabled]
Using host libthread_db library "/lib/x86_64-linux-gnu/libthread_db.so.1".

Program received signal SIGSEGV, Segmentation fault.
0x0000000000436917 in std.path.__T15extSeparatorPosTaZ.extSeparatorPos() (path=...) at /opt/gdc/include/d/4.8.0/std/path.d:629
629	    while (i >= 0 && !isSeparator(path[i]))

One thing is very clearly wrong here:

(gdb) print path.length
$1 = 140737488345808
(gdb) print path.ptr
$2 = 0x7fffffffe82b "test0.mci"

The length is completely wrong, but the pointer is OK. Let's go up a few frames:

(gdb) bt
#0  0x0000000000436917 in std.path.__T15extSeparatorPosTaZ.extSeparatorPos() (path=...) at /opt/gdc/include/d/4.8.0/std/path.d:629
#1  0x000000000043678b in std.path.__T9extensionTaZ.extension() (path=...) at /opt/gdc/include/d/4.8.0/std/path.d:656
#2  0x00000000005bc828 in mci.core.code.modules.ModuleSaver.save() (this=0x7fffffffda90) at ../src/mci/core/code/modules.d:410
#3  0x00000000004bd83d in mci.vm.io.writer.ModuleWriter.save() (this=..., module_=..., path=...) at ../src/mci/vm/io/writer.d:37
#4  0x0000000000432f0e in mci.cli.tools.assembler.AssemblerTool.run() (this=..., args=...) at ../src/mci/cli/tools/assembler.d:195
#5  0x000000000040622f in mci.cli.main.run() (args=...) at ../src/mci/cli/main.d:159
#6  0x0000000000406527 in D main (args=...) at ../src/mci/cli/main.d:202
#7  0x00000000006206a1 in rt.dmain2.main.runMain (this=0x7fffffffe360) at ../../../../gcc-4.8-20121014/libphobos/libdruntime/rt/dmain2.d:569
#8  0x0000000000620dff in rt.dmain2.main() (this=this@entry=0x7fffffffe360, dg=...) at ../../../../gcc-4.8-20121014/libphobos/libdruntime/rt/dmain2.d:544
#9  0x0000000000620fb0 in rt.dmain2.main.runAll (this=0x7fffffffe360) at ../../../../gcc-4.8-20121014/libphobos/libdruntime/rt/dmain2.d:579
#10 0x0000000000620dff in rt.dmain2.main() (this=this@entry=0x7fffffffe360, dg=...) at ../../../../gcc-4.8-20121014/libphobos/libdruntime/rt/dmain2.d:544
#11 0x0000000000620f15 in main (argc=7, argv=0x7fffffffe498) at ../../../../gcc-4.8-20121014/libphobos/libdruntime/rt/dmain2.d:588
(gdb) frame 3
#3  0x00000000004bd83d in mci.vm.io.writer.ModuleWriter.save() (this=..., module_=..., path=...) at ../src/mci/vm/io/writer.d:37
37	    public void save(Module module_, string path)
(gdb) print path.length
$3 = 30
(gdb) print path.ptr
$4 = 0x7fffffffe816 "tests/assembler/pass/test0.mci"

Looks OK. Then:

(gdb) print path.length
$5 = 140737488345680
(gdb) print path.ptr
$6 = 0x5bc828 <mci.core.code.modules.ModuleSaver.save()+258> "H\211\301H\211\323H\211\316H\211\320A\270"
(gdb) print path.length
$5 = 140737488345680
(gdb) print path.ptr
$6 = 0x5bc828 <mci.core.code.modules.ModuleSaver.save()+258> "H\211\301H\211\323H\211\316H\211\320A\270"

I'm pretty sure GDC is generating bad code here...
Comment 1 Alex Rønne Petersen 2012-10-21 15:39:44 CEST
Sorry, the last steps should have been:

(gdb) frame 2
(gdb) print path.length
$5 = 140737488345680
(gdb) print path.ptr
$6 = 0x5bc828 <mci.core.code.modules.ModuleSaver.save()+258>
"H\211\301H\211\323H\211\316H\211\320A\270"
Comment 2 Iain Buclaw 2013-04-12 13:32:05 CEST
Have re-tested this with fresh copy of mci on current development and get a load of 'Could not open file' errors.

Only change can think of is the 2.062 merge.  Does this work when using dmd?