www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 6761] New: Strange behavior of RedBlackTree causeing a dangling pointer

reply d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=6761

           Summary: Strange behavior of RedBlackTree causeing a dangling
                    pointer
           Product: D
           Version: D2
          Platform: x86
        OS/Version: Linux
            Status: NEW
          Severity: blocker
          Priority: P2
         Component: DMD
        AssignedTo: nobody puremagic.com
        ReportedBy: tbolsh gmail.com



PDT ---
Created an attachment (id=1033)
Module where 2 classes are defined, initialization of RBT is done in inner
class constrcutor

That error I was trying to comprehend for a lot time and I still do not
understand its causes. To see it one need to compile first module and to
compile the second one with -unittest and run those unittests, like that:

dmd -c RedBlackTree_bug2_1.d
dmd -unittest RedBlackTree_bug2_2.d RedBlackTree_bug2_1.o -ofrbt_bug2
./rbt_bug2
0 3076390832 Not only length is damaged - everything is. In real life program dies with core dumped. I can't tell for sure, but the behavior looks like a dangling pointer. That code was working (with slight modification, because RBT is a struct there instead of class) in version 2.052. That prevent me from switching to newer versions of dmd and I consider this bug to be a blocking bug for me. This error was present in version 2.053 as well, but back then I was not able to extract it into small example. -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
Oct 03 2011
next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=6761




PDT ---
Created an attachment (id=1034)
Module where I try to use that classes and RBT

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Oct 03 2011
prev sibling next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=6761




PDT ---
So, that bug blocks me from switching to any dmd version past 2.052 (new
RedBlackTree implementation).

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Oct 03 2011
prev sibling next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=6761


Steven Schveighoffer <schveiguy yahoo.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |ASSIGNED
           Platform|x86                         |All
         AssignedTo|nobody puremagic.com        |schveiguy yahoo.com
         OS/Version|Linux                       |All



09:04:47 PDT ---
If you compile both modules without -unittest, the code works properly.  If you
compile the second file with unittest (even if the test code is in main()), the
code fails.

The reason is because the unit test version of RBT unintentionally has an extra
entry in the vtable when compared to the non-unittest version.  This was my
error, and I will submit a pull request to fix it.  The reason it didn't show
up when RedBlackTree was a struct is because structs don't have virtual
functions.

In order to get your code working, put final in front of the function
"arrayEqual".  i.e.:

final bool arrayEqual(T[] arr)

I'll close the bug when the pull request is implemented.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Oct 03 2011
prev sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=6761


Steven Schveighoffer <schveiguy yahoo.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|ASSIGNED                    |RESOLVED
         Resolution|                            |FIXED



10:14:56 PDT ---
https://github.com/D-Programming-Language/phobos/pull/285

https://github.com/D-Programming-Language/phobos/commit/fa93dbf5f4de218b7e00e5d0430d28b17acd226c

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Oct 03 2011