[Issue 17] New: Nasty interface contract bug

gdc-bugzilla at gdcproject.org gdc-bugzilla at gdcproject.org
Sun Oct 21 08:37:59 PDT 2012


http://gdcproject.org/bugzilla/show_bug.cgi?id=17

             Bug #: 17
           Summary: Nasty interface contract bug
    Classification: Unclassified
           Product: GDC
           Version: development
          Platform: All
        OS/Version: All
            Status: NEW
          Severity: critical
          Priority: Normal
         Component: gdc
        AssignedTo: ibuclaw at gdcproject.org
        ReportedBy: alex at lycus.org


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 at 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 at 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...

-- 
Configure issuemail: http://gdcproject.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are watching all issue changes.


More information about the D.gnu mailing list