D issues are now tracked on GitHub. This Bugzilla instance remains as a read-only archive.
Issue 4587 - Assert exception should not allocate
Summary: Assert exception should not allocate
Status: NEW
Alias: None
Product: D
Classification: Unclassified
Component: druntime (show other issues)
Version: D2
Hardware: All All
: P3 minor
Assignee: Sean Kelly
URL:
Keywords: bootcamp
Depends on:
Blocks:
 
Reported: 2010-08-05 07:54 UTC by Leandro Lucarella
Modified: 2024-12-07 13:31 UTC (History)
2 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this issue.
Description Leandro Lucarella 2010-08-05 07:54:45 UTC
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).
Comment 1 nfxjfg 2010-08-05 10:14:21 UTC
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.
Comment 2 Leandro Lucarella 2010-08-05 10:37:15 UTC
(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
Comment 3 anonymous4 2010-08-05 19:19:07 UTC
I think, GC should just use special kind of assert.
Comment 4 Leandro Lucarella 2010-08-05 20:30:55 UTC
(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?
Comment 5 Andrei Alexandrescu 2016-12-22 14:33:10 UTC
An embarrassment of riches.

https://github.com/dlang/druntime/pull/1714
https://github.com/dlang/druntime/pull/1710
Comment 6 dlangBugzillaToGithub 2024-12-07 13:31:06 UTC
THIS ISSUE HAS BEEN MOVED TO GITHUB

https://github.com/dlang/dmd/issues/17228

DO NOT COMMENT HERE ANYMORE, NOBODY WILL SEE IT, THIS ISSUE HAS BEEN MOVED TO GITHUB