[Issue 1190] Reference becoming null
d-bugmail at puremagic.com
d-bugmail at puremagic.com
Tue Sep 4 05:43:13 PDT 2007
http://d.puremagic.com/issues/show_bug.cgi?id=1190
arkangath at gmail.com changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|RESOLVED |REOPENED
Resolution|INVALID |
------- Comment #7 from arkangath at gmail.com 2007-09-04 07:43 -------
(In reply to comment #6)
> I've noticed that your code create something like :
> myNode.rNeigh.bNeigh == myNode
> So I assume it's your code fault, if you can't provide a smaller test case.
There is no such comparison on the code. All comparisons between nodes are made
with the "is" keyword. No "==" comparisons are performed on references and you
can confirm by searching all "==" on the code.
And as I said on the main post, I have tracked the problem to a single line
(marked in the source as "//This causes the
children (both) to die"). Decompilation of the source lines gives out
terrain.d:334 assert(myNode.rChild !is null);
00403402: 8b5d08 mov ebx, [ebp+0x8]
00403405: 8b0b mov ecx, [ebx]
00403407: 83790c00 cmp dword [ecx+0xc], 0x0
0040340b: 750a jnz 0x403417 MFKC7terrain7Terrain8TreeNodeZv
terrain.Terrain.split terrain.d:336
0040340d: b84e010000 mov eax, 0x14e
00403412: e849040000 call 0x403860 void terrain.__assert(int)
terrain.d:423
terrain.d:336 myNode.rNeigh.bNeigh=myNode.rChild;
00403417: 8b13 mov edx, [ebx]
00403419: 8b720c mov esi, [edx+0xc]
0040341c: 8b7a18 mov edi, [edx+0x18]
0040341f: 897710 mov [edi+0x10], esi
terrain.d:337 assert(myNode.rChild !is null);
00403422: 8b0b mov ecx, [ebx]
00403424: 83790c00 cmp dword [ecx+0xc], 0x0
00403428: 750a jnz 0x403434 MFKC7terrain7Terrain8TreeNodeZv
terrain.Terrain.split terrain.d:337
0040342a: b851010000 mov eax, 0x151
0040342f: e82c040000 call 0x403860 void terrain.__assert(int)
terrain.d:423
00403434: eb3c jmp 0x403472 MFKC7terrain7Terrain8TreeNodeZv
terrain.Terrain.split terrain.d:342
terrain.d:339 else if (myNode.rNeigh.rNeigh is myNode)
myNode.rNeigh.rNeigh=myNode.rChild;
00403436: 8b5508 mov edx, [ebp+0x8]
00403439: 8b1a mov ebx, [edx]
0040343b: 8b7318 mov esi, [ebx+0x18]
0040343e: 8b4e18 mov ecx, [esi+0x18]
00403441: 3bcb cmp ecx, ebx
00403443: 7510 jnz 0x403455 MFKC7terrain7Terrain8TreeNodeZv
terrain.Terrain.split terrain.d:340
00403445: 8b4508 mov eax, [ebp+0x8]
00403448: 8b10 mov edx, [eax]
0040344a: 8b5a0c mov ebx, [edx+0xc]
0040344d: 8b7218 mov esi, [edx+0x18]
00403450: 895e18 mov [esi+0x18], ebx
00403453: eb1d jmp 0x403472 MFKC7terrain7Terrain8TreeNodeZv
terrain.Terrain.split terrain.d:342
You can confirm the code with ddbg.
The problem isn't with my code, as I have said on the original post, the code
was copied from my functional implementation on C (which I can provide if
necessary) and I have confimed that EVERY LINE was been correctly ported. A
single "copy" operation is cause two references to become null, references
which are only read, not written to, on the faulty operation.
--
More information about the Digitalmars-d-bugs
mailing list