www.digitalmars.com         C & C++   DMDScript  

digitalmars.D - Is it a Bug?

reply "Chris R. Miller" <lordSaurontheGreat gmail.com> writes:
Content-Type: text/plain; charset=ISO-8859-1; format=flowed
Content-Transfer-Encoding: quoted-printable

I have code which runs when built by GDC on OS X, but fails=20
spectacularly on DMD 1.030 and 1.033 on Windows.  I'm not sure what to=20
think, since DDBG isn't working well enough to import the rest of the=20
source files to unroll the stack far enough for me to find the offending =

line and work around it.

It's also a really big and scary "it doesn't work" situation.  I know so =

little about what's failing that I cannot make an effective test case to =

find the exact behavior that's not working.  I'd think it was my code if =

it weren't that
a) It compiles fine.
b) When built by GDC it runs fine.

The issue is with a funky data structure I wrote to store parts of a=20
video game map with many different actors on each tile, with actors that =

can exist on more than one tile at a time.  So knowing that it should be =

easier for you to follow what the program is trying to do.

It's a test-case I wrote to ensure my data structure works as intended.=20
  The test case starts here:

http://www.fsdev.net/repositories/entry/tick/trunk/tick/test/AMapSectionT=
est.d?rev=3D13

And is built to test the functionality of this type:


http://www.fsdev.net/repositories/entry/tick/trunk/tick/common/AMapSectio=
n.d?rev=3D13

And it uses two types defined here:

http://www.fsdev.net/repositories/entry/tick/trunk/tick/common/MapArea.d?=
rev=3D13
http://www.fsdev.net/repositories/entry/tick/trunk/tick/common/MapCoord.d=
?rev=3D13

DDBG tells me this:

Lord Sauron PRIMARY-COMPUTA:C:\Users\Lord Sauron\Desktop\tick\tick> ddbg =

bin\Tes
tAMapSection.exe
Ddbg 0.11.3 beta - D Debugger
Copyright (c) 2007 Jascha Wetzel
see http://ddbg.mainia.de/doc.html for documentation

Loading symbols from bin\TestAMapSection.exe
->r
No symbols available from ntdll.dll
ntdll.dll loaded at 0x772a0000
No symbols available from KERNEL32.dll
KERNEL32.dll loaded at 0x76e30000
No symbols available from SHELL32.dll
SHELL32.dll loaded at 0x760d0000
No symbols available from msvcrt.dll
msvcrt.dll loaded at 0x77050000
No symbols available from GDI32.dll
GDI32.dll loaded at 0x75d30000
No symbols available from USER32.dll
USER32.dll loaded at 0x76030000
No symbols available from ADVAPI32.dll
ADVAPI32.dll loaded at 0x77100000
No symbols available from RPCRT4.dll
RPCRT4.dll loaded at 0x771d0000
No symbols available from SHLWAPI.dll
SHLWAPI.dll loaded at 0x75b70000
Unknown breakpoint hit at ntdll.dll (0x772e7dfe) thread(2284)
No symbols available from IMM32.dll
IMM32.dll loaded at 0x75b20000
No symbols available from MSCTF.dll
MSCTF.dll loaded at 0x75f60000
No symbols available from LPK.dll
LPK.dll loaded at 0x75ed0000
No symbols available from USP10.dll
USP10.dll loaded at 0x75ee0000
No symbols available from GoogleDesktopNetwork3.DLL
GoogleDesktopNetwork3.DLL loaded at 0x48000000
No symbols available from WS2_32.dll
WS2_32.dll loaded at 0x76c70000
No symbols available from NSI.dll
NSI.dll loaded at 0x77040000
No symbols available from NTMARTA.dll
NTMARTA.dll loaded at 0x75980000
No symbols available from WLDAP32.dll
WLDAP32.dll loaded at 0x77420000
No symbols available from PSAPI.DLL
PSAPI.DLL loaded at 0x75a80000
No symbols available from SAMLIB.dll
SAMLIB.dll loaded at 0x75960000
No symbols available from ole32.dll
ole32.dll loaded at 0x75bd0000
No symbols available from COMCTL32.dll
COMCTL32.dll loaded at 0x74a70000
Testing common.AMapSection
Unhandled Exception: EXCEPTION_ACCESS_VIOLATION(0xc0000005) at=20
typeinfo.ti_C.Typ
eInfo_C.getHash (0x0040c2b0) thread(2284)
->us
#0 uint typeinfo.ti_C.TypeInfo_C.getHash(void*, void*) () at=20
test\AMapSectionTes
t.d:38 from ti_C
#1 0x0040218a in _Dmain () at test\AMapSectionTest.d:38
#2 0x004096d4 in extern (C) int dmain2.main(int, char**) . void=20
runMain(void*) (
) from dmain2
#3 0x0040970b in extern (C) int dmain2.main(int, char**) . void=20
runAll(void*) ()
  from dmain2
#4 0x0040944c in _main () from dmain2
#5 0x0041283d in _mainCRTStartup () from constart
#6 0x76e74911 in ?? () from KERNEL32.dll
#7 0x772de4b6 in ?? () from ntdll.dll
#8 0x772de489 in ?? () from ntdll.dll
->

It appears to be choking on some odd "getHash" function call, which is=20
interesting because the only hashing function I know of is toHash in=20
MapCoord:

http://www.fsdev.net/repositories/entry/tick/trunk/tick/common/MapCoord.d=
?rev=3D13#L32

I know that it's trying to use toHash correctly because GDC does it just =

fine (puts the right actors into the right place based on their unique=20
hash value, or their almost unique value, anyways...  Never mind, the=20
maps don't get big enough for too many collisions, anyways).

So if anyone knows how to coax a little more info from DDBG, knows a=20
workaround, or even know what's going wrong, I'd really appreciate it.
Aug 05 2008
parent reply "Vladimir Panteleev" <thecybershadow gmail.com> writes:
On Wed, 06 Aug 2008 08:29:44 +0300, Chris R. Miller  
<lordSaurontheGreat gmail.com> wrote:

 I have code which runs when built by GDC on OS X, but fails
 spectacularly on DMD 1.030 and 1.033 on Windows.  I'm not sure what to
 think, since DDBG isn't working well enough to import the rest of the
 source files to unroll the stack far enough for me to find the offending
 line and work around it.

Here's your bug: 16 this(bool n,MapCoord[] p...){ 17 Normalized=n; 18 Points=p; 19 } DMD allocates variadic parameter arrays on the stack, so "p" (and "Points") contain a slice of memory on the stack. Change line 18 to "Points=p.dup;" and it'll work. You're welcome :) -- Best regards, Vladimir mailto:thecybershadow gmail.com
Aug 05 2008
next sibling parent "Chris R. Miller" <lordSaurontheGreat gmail.com> writes:
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: quoted-printable

Vladimir Panteleev wrote:
 On Wed, 06 Aug 2008 08:29:44 +0300, Chris R. Miller=20
 <lordSaurontheGreat gmail.com> wrote:
=20
 I have code which runs when built by GDC on OS X, but fails
 spectacularly on DMD 1.030 and 1.033 on Windows.  I'm not sure what to=


 think, since DDBG isn't working well enough to import the rest of the
 source files to unroll the stack far enough for me to find the offendi=


 line and work around it.

Here's your bug: =20 16 this(bool n,MapCoord[] p...){ 17 Normalized=3Dn; 18 Points=3Dp; 19 } =20 DMD allocates variadic parameter arrays on the stack, so "p" (and=20 "Points") contain a slice of memory on the stack. =20 Change line 18 to "Points=3Dp.dup;" and it'll work.

Wow, I didn't remember that. Thanks, I probably would not have caught=20 that bug if left to my own devices.
Aug 06 2008
prev sibling parent "Koroskin Denis" <2korden gmail.com> writes:
On Wed, 06 Aug 2008 12:25:43 +0400, Chris R. Miller  
<lordSaurontheGreat gmail.com> wrote:

 Vladimir Panteleev wrote:
 On Wed, 06 Aug 2008 08:29:44 +0300, Chris R. Miller
 <lordSaurontheGreat gmail.com> wrote:

 I have code which runs when built by GDC on OS X, but fails
 spectacularly on DMD 1.030 and 1.033 on Windows.  I'm not sure what to
 think, since DDBG isn't working well enough to import the rest of the
 source files to unroll the stack far enough for me to find the  
 offending
 line and work around it.

Here's your bug: 16 this(bool n,MapCoord[] p...){ 17 Normalized=n; 18 Points=p; 19 } DMD allocates variadic parameter arrays on the stack, so "p" (and "Points") contain a slice of memory on the stack. Change line 18 to "Points=p.dup;" and it'll work.

Wow, I didn't remember that. Thanks, I probably would not have caught that bug if left to my own devices.

How about a bug report?
Aug 06 2008