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.