Bug 20650 – Cryptic error message when GC called in finalizer

Status
RESOLVED
Resolution
FIXED
Severity
enhancement
Priority
P4
Component
druntime
Product
D
Version
D2
Platform
x86_64
OS
Linux
Creation time
2020-03-09T10:08:45Z
Last change time
2022-12-26T03:24:11Z
Keywords
diagnostic, pull
Assigned to
No Owner
Creator
FeepingCreature

Comments

Comment #0 by default_357-line — 2020-03-09T10:08:45Z
Consider the following code: class Foo { ~this() { new int; } } void main() { new Foo; } What I expected: core.exception.ReentrantFinalizerException: GC called while finalizing memory. Are your destructors @nogc? What I got: core.exception.InvalidMemoryOperationError@src/core/exception.d(647): Invalid memory operation This is cryptic at best and actively misleading at worst, due to the confusion potential with segfaults. The error message should be made clearer.
Comment #1 by dlang-bot — 2022-12-18T01:19:28Z
@schveiguy created dlang/dmd pull request #14710 "Remove GC for allocating traceinfo" fixing this issue: - Remove GC for allocating traceinfo. Allow traces for InvalidMemoryOperationError and other sensitive errors. Fixes 20650 Fixes 16641 Fixes 22616 https://github.com/dlang/dmd/pull/14710
Comment #2 by dlang-bot — 2022-12-26T03:24:11Z
dlang/dmd pull request #14710 "Avoid GC for allocating traceinfo" was merged into master: - 374f20760e6c6183861dc599e1fb6379830a032a by Steven Schveighoffer: Avoid GC for allocating traceinfo. Allow traces for InvalidMemoryOperationError and other sensitive errors. Fixes 20650,16641,22616. https://github.com/dlang/dmd/pull/14710