Bug 9275 – [GC] removeRoot hits assert(0) instead of being a no-op (as documented)

Status
RESOLVED
Resolution
FIXED
Severity
normal
Priority
P2
Component
druntime
Product
D
Version
D2
Platform
All
OS
All
Creation time
2013-01-06T11:58:00Z
Last change time
2017-08-07T12:25:58Z
Keywords
bootcamp
Assigned to
nobody
Creator
dmitry.olsh

Comments

Comment #0 by dmitry.olsh — 2013-01-06T11:58:23Z
Documentation clearly states that it's possible to call removeRoot on something that wasn't added by addRoot: static nothrow void removeRoot(in void* p); Removes the memory block referenced by p from an internal list of roots to be scanned during a collection. If p is null or is not a value previously passed to addRoot() then no operation is performed. import core.memory; void main() { // this will work fine GC.removeRoot(null); //this will boom once liner search fails to find '13' among roots //It does the same with any sane pointer that isn't a root GC.removeRoot(cast(void*)13); } Output: object.Error: assert(0) or HLT instruction ---------------- 0x0040BEB0 0x0040BD3B 0x770E30F1 in RtlRaiseStatus 0x770E30C3 in RtlRaiseStatus 0x770E2F2B in KiUserExceptionDispatcher 0x00403160 0x0040260E 0x00402211 0x00402034 0x76AF8543 in BaseThreadInitThunk 0x770FAC69 in RtlInitializeExceptionChain 0x770FAC3C in RtlInitializeExceptionChain ----------------
Comment #1 by 4burgos — 2016-10-20T17:58:21Z
Looks like this has been fixed in the meantime: ``` import core.memory; void main() { // this will work fine GC.removeRoot(null); //this will boom once liner search fails to find '13' among roots //It does the same with any sane pointer that isn't a root GC.removeRoot(cast(void*)13); } ```
Comment #2 by safety0ff.bugz — 2016-10-20T22:49:02Z
A unit test should be added and then this bug should be closed.
Comment #3 by 4burgos — 2016-10-21T05:36:10Z
Comment #4 by github-bugzilla — 2017-06-07T06:42:33Z
Commit pushed to master at https://github.com/dlang/druntime https://github.com/dlang/druntime/commit/a1fb3915f562428741324ac5b319d9316fb57231 Fix issue 9275: Add test for removeRoot Issue 9275 describes the runtime crashing on the invalid pointer passed to removeRoot, instead of documented no-op. This has been fixed in the meantime, so unittest is added as a guarantee that it stays so.
Comment #5 by github-bugzilla — 2017-06-17T11:34:33Z
Comment #6 by github-bugzilla — 2017-08-07T12:25:58Z