Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Assert exception should not allocate #17228

Open
dlangBugzillaToGithub opened this issue Aug 5, 2010 · 5 comments
Open

Assert exception should not allocate #17228

dlangBugzillaToGithub opened this issue Aug 5, 2010 · 5 comments
Labels

Comments

@dlangBugzillaToGithub
Copy link

Leandro Lucarella (@leandro-lucarella-sociomantic) reported this on 2010-08-05T07:54:45Z

Transferred from https://issues.dlang.org/show_bug.cgi?id=4587

CC List

Description

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).
@dlangBugzillaToGithub
Copy link
Author

nfxjfg commented on 2010-08-05T10:14:21Z

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.

@dlangBugzillaToGithub
Copy link
Author

leandro.lucarella (@leandro-lucarella-sociomantic) commented on 2010-08-05T10:37:15Z

(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

@dlangBugzillaToGithub
Copy link
Author

dfj1esp02 commented on 2010-08-05T19:19:07Z

I think, GC should just use special kind of assert.

@dlangBugzillaToGithub
Copy link
Author

leandro.lucarella (@leandro-lucarella-sociomantic) commented on 2010-08-05T20:30:55Z

(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?

@dlangBugzillaToGithub
Copy link
Author

andrei (@andralex) commented on 2016-12-22T14:33:10Z

An embarrassment of riches.

https://github.com/dlang/druntime/pull/1714
https://github.com/dlang/druntime/pull/1710

@thewilsonator thewilsonator added the Druntime Specific to druntime label Dec 8, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants