www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 8924] New: Delegate becomes invalid after a while

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

           Summary: Delegate becomes invalid after a while
           Product: D
           Version: D2
          Platform: x86_64
        OS/Version: Linux
            Status: NEW
          Severity: normal
          Priority: P2
         Component: DMD
        AssignedTo: nobody puremagic.com
        ReportedBy: malteskarupke web.de



PDT ---
Created an attachment (id=1158)
Run this file and you should get a segmentation fault.

I have a bug that was quite a mess to figure out because it seemed to happen
randomly. It turns out that a delegate with stack references becomes invalid
after the program has run for a while.

I don't have a concise repro-case, but I've attached a file which shows the
problem somewhat concisely. If you run it you should see a segmentation fault.

In that file you'll see a loop in line 437, which counts from 0 to 10000. If I
change that loop to count only to 1000, the bug doesn't happen. So if you don't
experience the bug, try changing it to 100000 and see if the bug then happens.
That loop simply does unrelated work and the amount of times it runs shouldn't
affect the bug at all, but somehow it does.

If I'm doing something invalid in the code, it should crash right away and not
work at first and then stop working after a while.

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


Maxim Fomin <maxim maxim-fomin.ru> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |maxim maxim-fomin.ru



---
It seems that the problem is introduced by someUnrelatedComplexity function. If
it is dropped, everything works fine. If everything is dropped but
someUnrelatedComplexity, everything still works fine, however valgrind
complains about many errors related using non initialized variables and
erroneous conditional jumps in gc_gcx_mark() and fullcollect(). Keeps
everything same to your attachment causes similar errors (but because of
already corrupted heap your code segfaults in disconnect function on accessing
slots.length). Reducing number of loops as you propose, makes errors gone.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Nov 01 2012
prev sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=8924


Malte Skarupke <malteskarupke web.de> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
         Resolution|                            |INVALID
           Severity|normal                      |critical



PDT ---
I've debugged it further and it was an issue with the garbage collector. I was
using malloc and free but I wasn't calling GC.addRange and GC.removeRange.

This now provides me with another problem because I specifically did not want
the garbage collector to know about that memory, so that it wouldn't keep
certain objects alive. Unfortunately that means that it then collects too much.
I'll find a solution, but this bug is closed.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Nov 01 2012