www.digitalmars.com         C & C++   DMDScript  

digitalmars.D - OutOfMemoryException not being thrown

When running out of memory, I got:-
Program received signal SIGSEGV, Segmentation fault.

This was generated on a linux box, using dmd 0.111 and the prebuilt
libphobos.a and glibc 2.3.3. I wrote a simple prog. to create a array of
objects and limited the memory it was permitted with "ulimit -v 8000".

I traced what appears to be a bug in file gc.d, function _d_newclass. The
function didn't check the result of _gc.malloc. I changed the source as

<       debug(PRINTF) printf(" p = %p\n", p);
<       _gc.setFinalizer(p, &new_finalizer);
         if (!p)
             debug(PRINTF) printf(" p = %p\n", p);
             _gc.setFinalizer(p, &new_finalizer);

Now an exception is thrown and can be caught. (Then memory released). I then checked back to the dmd 0.110 source to find the correct code commented out! My libphobos.a file turns out to be quite a bit bigger than the one shipped, 843522 instead of 839742. I used the shipped linux.mak and gcc 3.3.4. Regards, Paul Clinch.
Jan 23 2005