Download Reference Manual
The Developer's Library for D
About Wiki Forums Source Search Contact

Ticket #990 (closed defect: fixed)

Opened 7 months ago

Last modified 1 month ago

Segfault when inserting an interface into a Variant and retrieving as object

Reported by: dhasenan Assigned to: sean
Priority: major Milestone: 0.99.8
Component: Core Functionality Version: 0.99.5 Jascha
Keywords: triage Cc:

Description

import tango.core.Variant;
interface IBar {}
class Foo : IBar {}

void main()
{
    IBar bar = new Foo();
    Variant var = bar;
    Foo foo = var.get!(Foo); // segfaults
}

Attachments

variant.patch (0.6 kB) - added by dhasenan on 08/30/08 16:38:46.
patch to correct the behavior

Change History

03/21/08 10:34:36 changed by larsivi

Can you provide some more information on your system? Arch and compiler version, please.

03/21/08 10:44:32 changed by larsivi

Confirmed on Linux X86 using both DMD 1.028 and GDC latest SVN with these backtraces:

DMD:

#0  0x0804de07 in _d_isbaseof2 ()
#1  0x0804de64 in _d_isbaseof2 ()
#2  0x0804dddf in _d_dynamic_cast ()
#3  0x08049152 in _D5tango4core7Variant7Variant18__T3getTC3foo3FooZ3getMFZC3foo3Foo ()
#4  0x08049011 in _Dmain ()
#5  0x0804e41c in _D6dmain24mainUiPPaZi7runMainMFZv ()
#6  0x0804e1f1 in _D6dmain24mainUiPPaZi7tryExecMFDFZvZv ()
#7  0x0804e459 in _D6dmain24mainUiPPaZi6runAllMFZv ()
#8  0x0804e1f1 in _D6dmain24mainUiPPaZi7tryExecMFDFZvZv ()
#9  0x0804e19a in main ()

GDC:

#0  _d_isbaseof2 (oc=@0x8071648, c=@0x8071600, offset=@0xbfa9f5a0) at cast.d:115
#1  0x080606b7 in _d_dynamic_cast (o=@0xb7cdfff8, c=@0x8071600) at cast.d:90
#2  0x0805abaf in _D5tango4core7Variant7Variant18__T3getTC3foo3FooZ3getMFZC3foo3Foo ()
#3  0x0805a9d6 in _Dmain ()
#4  0x080607db in runMain () at dgccmain2.d:285
#5  0x08060955 in tryExec (dg={object = 0x0, func = 0x8097000}) at dgccmain2.d:233
#6  0x08060f4c in runAll () at dgccmain2.d:293
#7  0x08060955 in tryExec (dg={object = 0x0, func = 0x8097000}) at dgccmain2.d:233
#8  0x08060e43 in _d_run_main (argc=1, argv=0xbfa9f924, main_func=0x805a954 <_Dmain>)
    at dgccmain2.d:300
#9  0x0805c50a in main (argc=Cannot access memory at address 0x3a93
) at cmain.d:5

04/27/08 05:11:29 changed by larsivi

  • milestone changed from 0.99.6 to 0.99.7.

05/12/08 11:23:53 changed by larsivi

  • keywords set to triage.

This now works on Linux for both compilers - which is somewhat curious if it was a compiler bug (not so curious with DMD, but I haven't upgraded GDC) - dhasenan, does this still error out for you? And if so, where and with which compiler?

07/10/08 07:01:49 changed by larsivi

  • milestone changed from 0.99.7 to 0.99.8.

07/26/08 13:15:08 changed by sean

  • status changed from new to assigned.

Oops... and I just rejected a dup of this ticket. Oh well... I guess it's been fixed in the code anyway. I'll change it. For what it's worth, this works fine on DMD / Win32, so if any problem persists then it's a compiler bug. If the issue persists, please update this ticket with a compiler version. If we make it to the next release and this ticket is unchanged then I'll assume it's no longer and issue.

08/30/08 16:34:12 changed by dhasenan

Sorry, this is still segfaulting on Linux.

Stack trace (dmd1.034)

#0  0x08049d67 in _d_isbaseof2 ()
#1  0x08049dc4 in _d_isbaseof2 ()
#2  0x08049d3f in _d_dynamic_cast ()
#3  0x08049142 in _D5tango4core7Variant7Variant18__T3getTC3bar3FooZ3getMFZC3bar3Foo ()
#4  0x08049001 in _Dmain ()
#5  0x0804991c in _D6dmain24mainUiPPaZi7runMainMFZv ()
#6  0x080496f1 in _D6dmain24mainUiPPaZi7tryExecMFDFZvZv ()
#7  0x08049959 in _D6dmain24mainUiPPaZi6runAllMFZv ()
#8  0x080496f1 in _D6dmain24mainUiPPaZi7tryExecMFDFZvZv ()
#9  0x0804969a in main ()

08/30/08 16:38:46 changed by dhasenan

  • attachment variant.patch added.

patch to correct the behavior

08/30/08 16:40:48 changed by dhasenan

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

Oops, I just updated; it works now.