Thread overview
[Issue 4587] New: Assert exception should not allocate
Aug 05, 2010
Leandro Lucarella
Aug 05, 2010
nfxjfg@gmail.com
Aug 05, 2010
Leandro Lucarella
Aug 06, 2010
Sobirari Muhomori
Aug 06, 2010
Leandro Lucarella
August 05, 2010
http://d.puremagic.com/issues/show_bug.cgi?id=4587

           Summary: Assert exception should not allocate
           Product: D
           Version: D1 & D2
          Platform: All
        OS/Version: All
            Status: NEW
          Severity: minor
          Priority: P2
         Component: druntime
        AssignedTo: sean@invisibleduck.org
        ReportedBy: llucax@gmail.com


--- Comment #0 from Leandro Lucarella <llucax@gmail.com> 2010-08-05 07:54:45 PDT ---
If an assert error allocates memory, the GC allocation code can't use assert, because it enters in an infinite recursion if the assertion fail.

Since OutOfMemory don't allocate, I think a similar trick can be done for assert. Is not too bad the current situation, because it only affects the GC, but it would be nice to be able to use assert inside the GC without having to be very careful that the assert is not used in the code path for allocation (which includes the collection itself).

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
August 05, 2010
http://d.puremagic.com/issues/show_bug.cgi?id=4587


nfxjfg@gmail.com changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |nfxjfg@gmail.com


--- Comment #1 from nfxjfg@gmail.com 2010-08-05 10:14:21 PDT ---
This is a bit comical, because the GC (gcx.d) already uses lots of asserts. They are just disabled, because Phobos is compiled in release mode.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
August 05, 2010
http://d.puremagic.com/issues/show_bug.cgi?id=4587



--- Comment #2 from Leandro Lucarella <llucax@gmail.com> 2010-08-05 10:37:15 PDT ---
(In reply to comment #1)
> This is a bit comical, because the GC (gcx.d) already uses lots of asserts. They are just disabled, because Phobos is compiled in release mode.

The good (?) news is the program still aborts when the assert fails, but
because of a segmentation fault for stack exhaustion :)

Asking GDB for a backtrace is not fun at all =P

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
August 06, 2010
http://d.puremagic.com/issues/show_bug.cgi?id=4587



--- Comment #3 from Sobirari Muhomori <dfj1esp02@sneakemail.com> 2010-08-05 19:19:07 PDT ---
I think, GC should just use special kind of assert.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
August 06, 2010
http://d.puremagic.com/issues/show_bug.cgi?id=4587



--- Comment #4 from Leandro Lucarella <llucax@gmail.com> 2010-08-05 20:30:55 PDT ---
(In reply to comment #3)
> I think, GC should just use special kind of assert.

Why? And how is desirable that an assert allocates?

I agree that the GC *could* use a special kind of assert, as I said it's really not that bad, but I don't see how it *should*. The GC have to do a lot of special casing already if it's written in D, how adding more special cases for the GC developers is good?

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