[phobos] Strange access violation Mandelbug with AAs + Appender

Shin Fujishiro rsinfu at gmail.com
Thu Aug 19 12:07:31 PDT 2010


David Simcha <dsimcha at gmail.com> wrote:
> http://d.puremagic.com/issues/show_bug.cgi?id=4681
> 
> This is a really bad one.  Someone please check to make sure I'm not doing
> anything really silly and that this isn't specific to some obscure detail of
> my setup.  If others can reproduce this, it's a really bad one and probably
> warrants an emergency release.

Seems like a bug of Appender.writeCapacity().  It often writes 'cap' to
wrong address; the following assertion fails:
==========
diff --git phobos/std/array.d phobos/std/array.d
index 6b62733..e6d3a62 100644
--- phobos/std/array.d
+++ phobos/std/array.d
@@ -736,10 +736,12 @@ private:
         auto p = cast(ubyte*) (pArray.ptr + pArray.length);
         if (cap < ubyte.max)
         {
+            assert(p + 1 <= GC.addrOf(pArray.ptr) + GC.sizeOf(pArray.ptr));
             *p = cast(ubyte) cap;
         }
         else if (cap < ushort.max)
         {
+            assert(p + 3 <= GC.addrOf(pArray.ptr) + GC.sizeOf(pArray.ptr));
             *p++ = ubyte.max;
             *p++ = cast(ubyte) cap;
             *p++ = cast(ubyte) (cap >> 8);
==========


Shin


More information about the phobos mailing list